From 013fb33972061ac65cdf3e1771267985e59deca1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 30 Oct 2007 10:34:33 +0100 Subject: SG: Make sg_init_one() use general table init functions Don't open code sg_init_one(), make it reuse sg_init_table(). Signed-off-by: Jens Axboe --- include/linux/scatterlist.h | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 32326c293d7..d5e1876daf3 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -205,28 +205,6 @@ static inline void __sg_mark_end(struct scatterlist *sg) sg->page_link |= 0x02; } -/** - * sg_init_one - Initialize a single entry sg list - * @sg: SG entry - * @buf: Virtual address for IO - * @buflen: IO length - * - * Notes: - * This should not be used on a single entry that is part of a larger - * table. Use sg_init_table() for that. - * - **/ -static inline void sg_init_one(struct scatterlist *sg, const void *buf, - unsigned int buflen) -{ - memset(sg, 0, sizeof(*sg)); -#ifdef CONFIG_DEBUG_SG - sg->sg_magic = SG_MAGIC; -#endif - sg_mark_end(sg, 1); - sg_set_buf(sg, buf, buflen); -} - /** * sg_init_table - Initialize SG table * @sgl: The SG table @@ -250,6 +228,24 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) #endif } +/** + * sg_init_one - Initialize a single entry sg list + * @sg: SG entry + * @buf: Virtual address for IO + * @buflen: IO length + * + * Notes: + * This should not be used on a single entry that is part of a larger + * table. Use sg_init_table() for that. + * + **/ +static inline void sg_init_one(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg_init_table(sg, 1); + sg_set_buf(sg, buf, buflen); +} + /** * sg_phys - Return physical address of an sg entry * @sg: SG entry -- cgit v1.2.3 From 87ae9afdcada236d0a1b38ce2c465a65916961dc Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 30 Oct 2007 10:35:04 +0100 Subject: cleanup asm/scatterlist.h includes Not architecture specific code should not #include . This patch therefore either replaces them with #include or simply removes them if they were unused. Signed-off-by: Adrian Bunk Signed-off-by: Jens Axboe --- crypto/anubis.c | 1 - crypto/blowfish.c | 1 - crypto/compress.c | 1 - crypto/crypto_null.c | 1 - crypto/khazad.c | 1 - crypto/sha1_generic.c | 1 - crypto/sha256_generic.c | 1 - crypto/sha512.c | 1 - crypto/tea.c | 1 - crypto/tgr192.c | 1 - crypto/wp512.c | 1 - drivers/base/dmapool.c | 1 - drivers/ieee1394/sbp2.c | 2 +- drivers/media/video/bt8xx/bttvp.h | 2 +- drivers/mmc/core/core.c | 1 - drivers/mmc/core/mmc_ops.c | 1 - drivers/mmc/core/sd_ops.c | 1 - drivers/mmc/core/sdio_ops.c | 1 - drivers/net/meth.c | 1 - drivers/usb/core/buffer.c | 1 - drivers/usb/core/hcd.c | 1 - drivers/usb/core/usb.c | 2 +- fs/nfsd/nfs4recover.c | 2 +- include/net/esp.h | 2 +- include/rdma/ib_verbs.h | 2 +- include/scsi/libsas.h | 2 +- net/ieee80211/ieee80211_crypt_ccmp.c | 1 - net/ipv4/ah4.c | 1 - net/ipv4/ipcomp.c | 1 - net/ipv6/ah6.c | 1 - net/ipv6/ipcomp6.c | 1 - net/mac80211/aes_ccm.c | 1 - net/sunrpc/auth_gss/gss_krb5_seal.c | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 1 - net/xfrm/xfrm_algo.c | 1 - 35 files changed, 7 insertions(+), 35 deletions(-) diff --git a/crypto/anubis.c b/crypto/anubis.c index 1c771f7f4dc..4ff0e1e243a 100644 --- a/crypto/anubis.c +++ b/crypto/anubis.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/crypto/blowfish.c b/crypto/blowfish.c index 55238c4e37f..80c3fd8be97 100644 --- a/crypto/blowfish.c +++ b/crypto/blowfish.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/crypto/compress.c b/crypto/compress.c index 0a6570048c1..1ee357085d3 100644 --- a/crypto/compress.c +++ b/crypto/compress.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "internal.h" diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c index 24dbb5d8617..29f77477d70 100644 --- a/crypto/crypto_null.c +++ b/crypto/crypto_null.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include diff --git a/crypto/khazad.c b/crypto/khazad.c index 9fa24a2dd6f..704ebfe26b5 100644 --- a/crypto/khazad.c +++ b/crypto/khazad.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c index 48a3c3e0bf5..68c62f528eb 100644 --- a/crypto/sha1_generic.c +++ b/crypto/sha1_generic.c @@ -23,7 +23,6 @@ #include #include #include -#include #include struct sha1_ctx { diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c index 5f4332edcf6..fd3918be58b 100644 --- a/crypto/sha256_generic.c +++ b/crypto/sha256_generic.c @@ -22,7 +22,6 @@ #include #include #include -#include #include struct sha256_ctx { diff --git a/crypto/sha512.c b/crypto/sha512.c index e736596ca57..c39c803ecc0 100644 --- a/crypto/sha512.c +++ b/crypto/sha512.c @@ -19,7 +19,6 @@ #include #include -#include #include struct sha512_ctx { diff --git a/crypto/tea.c b/crypto/tea.c index 1c54e26fa52..6893b3fdf9d 100644 --- a/crypto/tea.c +++ b/crypto/tea.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/crypto/tgr192.c b/crypto/tgr192.c index a0fadf3dd3e..2e7ea1680c7 100644 --- a/crypto/tgr192.c +++ b/crypto/tgr192.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/crypto/wp512.c b/crypto/wp512.c index 727d05a19ff..f746952b93f 100644 --- a/crypto/wp512.c +++ b/crypto/wp512.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c index 5beddc322e6..b5034dc72a0 100644 --- a/drivers/base/dmapool.c +++ b/drivers/base/dmapool.c @@ -2,7 +2,6 @@ #include #include #include /* Needed for i386 to build */ -#include /* Needed for i386 to build */ #include #include #include diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index d5dfe11aa5c..b83d254bc86 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -71,11 +71,11 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h index 0b92c35a843..d4ac4c4b49b 100644 --- a/drivers/media/video/bt8xx/bttvp.h +++ b/drivers/media/video/bt8xx/bttvp.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 09435e0ec68..b96667448eb 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 7471d49909b..64b05c6270f 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -10,7 +10,6 @@ */ #include -#include #include #include diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index a6dafe62b99..0d96080d44b 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -10,7 +10,6 @@ */ #include -#include #include #include diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index 4d289b27503..e1fca588e38 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c @@ -9,7 +9,6 @@ * your option) any later version. */ -#include #include #include diff --git a/drivers/net/meth.c b/drivers/net/meth.c index e25dbab6736..0c89b028a80 100644 --- a/drivers/net/meth.c +++ b/drivers/net/meth.c @@ -33,7 +33,6 @@ #include #include -#include #include "meth.h" diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index ead2475406b..28d4972f7ad 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 3dd997df850..fea8256a18d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 69aa68287d3..c4a6f1095b8 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 6f03918018a..1602cd00dd4 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/net/esp.h b/include/net/esp.h index c1bc529809d..c05f529bff2 100644 --- a/include/net/esp.h +++ b/include/net/esp.h @@ -3,7 +3,7 @@ #include #include -#include +#include #define ESP_NUM_FAST_SG 4 diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 4bea182d711..11f39606e7d 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -48,9 +48,9 @@ #include #include #include +#include #include -#include #include union ib_gid { diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 8dda2d66b5b..a466c2cb895 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include struct block_device; diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c index 0936a3e0210..c6d760d9fbb 100644 --- a/net/ieee80211/ieee80211_crypt_ccmp.c +++ b/net/ieee80211/ieee80211_crypt_ccmp.c @@ -25,7 +25,6 @@ #include #include -#include MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: CCMP"); diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 4e8e3b079f5..5fc346d8b56 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -8,7 +8,6 @@ #include #include #include -#include /* Clear mutable options and find final destination to substitute diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index 0bfeb02a5f8..ca1b5fdb8d3 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c @@ -14,7 +14,6 @@ * - Adaptive compression. */ #include -#include #include #include #include diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index 66a9139d46e..4eaf55072b1 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -35,7 +35,6 @@ #include #include #include -#include static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr) { diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 80ef2a1d39f..85eb4798d8d 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index bf7ba128b96..e62fe55944b 100644 --- a/net/mac80211/aes_ccm.c +++ b/net/mac80211/aes_ccm.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include "ieee80211_key.h" diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c index a0d9faa59cb..1c6eda5077c 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seal.c +++ b/net/sunrpc/auth_gss/gss_krb5_seal.c @@ -63,7 +63,6 @@ #include #include #include -#include #include #ifdef RPC_DEBUG diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c index 8bd074df27d..3bdc527ee64 100644 --- a/net/sunrpc/auth_gss/gss_krb5_wrap.c +++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #ifdef RPC_DEBUG diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 0426388d351..1686f64c435 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c @@ -21,7 +21,6 @@ #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) #include #endif -#include /* * Algorithms supported by IPsec. These entries contain properties which -- cgit v1.2.3 From c46f2334c84c2b26baa64d42d75ddc5fab38c3dc Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 31 Oct 2007 12:06:37 +0100 Subject: [SG] Get rid of __sg_mark_end() sg_mark_end() overwrites the page_link information, but all users want __sg_mark_end() behaviour where we just set the end bit. That is the most natural way to use the sg list, since you'll fill it in and then mark the end point. So change sg_mark_end() to only set the termination bit. Add a sg_magic debug check as well, and clear a chain pointer if it is set. Signed-off-by: Jens Axboe --- block/ll_rw_blk.c | 2 +- drivers/scsi/scsi_lib.c | 2 +- include/linux/scatterlist.h | 22 ++++++++++++---------- net/core/skbuff.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- net/rxrpc/rxkad.c | 2 +- net/sunrpc/auth_gss/gss_krb5_crypto.c | 6 +++--- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 56f2646612e..54fd3858967 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -1369,7 +1369,7 @@ new_segment: } /* segments in rq */ if (sg) - __sg_mark_end(sg); + sg_mark_end(sg); return nsegs; } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 61fdaf02f25..88de771d356 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -785,7 +785,7 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) * end-of-list */ if (!left) - sg_mark_end(sgl, this); + sg_mark_end(&sgl[this - 1]); /* * don't allow subsequent mempool allocs to sleep, it would diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index d5e1876daf3..25973504414 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -188,21 +188,23 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, /** * sg_mark_end - Mark the end of the scatterlist - * @sgl: Scatterlist - * @nents: Number of entries in sgl + * @sg: SG entryScatterlist * * Description: - * Marks the last entry as the termination point for sg_next() + * Marks the passed in sg entry as the termination point for the sg + * table. A call to sg_next() on this entry will return NULL. * **/ -static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents) -{ - sgl[nents - 1].page_link = 0x02; -} - -static inline void __sg_mark_end(struct scatterlist *sg) +static inline void sg_mark_end(struct scatterlist *sg) { +#ifdef CONFIG_DEBUG_SG + BUG_ON(sg->sg_magic != SG_MAGIC); +#endif + /* + * Set termination bit, clear potential chain bit + */ sg->page_link |= 0x02; + sg->page_link &= ~0x01; } /** @@ -218,7 +220,6 @@ static inline void __sg_mark_end(struct scatterlist *sg) static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) { memset(sgl, 0, sizeof(*sgl) * nents); - sg_mark_end(sgl, nents); #ifdef CONFIG_DEBUG_SG { unsigned int i; @@ -226,6 +227,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) sgl[i].sg_magic = SG_MAGIC; } #endif + sg_mark_end(&sgl[nents - 1]); } /** diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 64b50ff7a41..32d5826b717 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2095,7 +2095,7 @@ int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int le { int nsg = __skb_to_sgvec(skb, sg, offset, len); - __sg_mark_end(&sg[nsg - 1]); + sg_mark_end(&sg[nsg - 1]); return nsg; } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index eec02b29ffc..d438dfb0c8f 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1083,7 +1083,7 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, sg_set_buf(&sg[block++], key->key, key->keylen); nbytes += key->keylen; - __sg_mark_end(&sg[block - 1]); + sg_mark_end(&sg[block - 1]); /* Now store the Hash into the packet */ err = crypto_hash_init(desc); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 4b903288095..06be2a1f273 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -781,7 +781,7 @@ static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, sg_set_buf(&sg[block++], key->key, key->keylen); nbytes += key->keylen; - __sg_mark_end(&sg[block - 1]); + sg_mark_end(&sg[block - 1]); /* Now store the hash into the packet */ err = crypto_hash_init(desc); diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index c387cf68a08..e09a95aa68f 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c @@ -702,7 +702,7 @@ static void rxkad_sg_set_buf2(struct scatterlist sg[2], nsg++; } - __sg_mark_end(&sg[nsg - 1]); + sg_mark_end(&sg[nsg - 1]); ASSERTCMP(sg[0].length + sg[1].length, ==, buflen); } diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index ab7cbd6575c..0dd792338fa 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c @@ -211,8 +211,8 @@ encryptor(struct scatterlist *sg, void *data) if (thislen == 0) return 0; - __sg_mark_end(&desc->infrags[desc->fragno - 1]); - __sg_mark_end(&desc->outfrags[desc->fragno - 1]); + sg_mark_end(&desc->infrags[desc->fragno - 1]); + sg_mark_end(&desc->outfrags[desc->fragno - 1]); ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags, desc->infrags, thislen); @@ -293,7 +293,7 @@ decryptor(struct scatterlist *sg, void *data) if (thislen == 0) return 0; - __sg_mark_end(&desc->frags[desc->fragno - 1]); + sg_mark_end(&desc->frags[desc->fragno - 1]); ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags, desc->frags, thislen); -- cgit v1.2.3