]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SG] Get rid of __sg_mark_end()
authorJens Axboe <jens.axboe@oracle.com>
Wed, 31 Oct 2007 11:06:37 +0000 (12:06 +0100)
committerJens Axboe <axboe@carl.home.kernel.dk>
Fri, 2 Nov 2007 07:47:06 +0000 (08:47 +0100)
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 <jens.axboe@oracle.com>
block/ll_rw_blk.c
drivers/scsi/scsi_lib.c
include/linux/scatterlist.h
net/core/skbuff.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c
net/rxrpc/rxkad.c
net/sunrpc/auth_gss/gss_krb5_crypto.c

index 56f2646612e604c2599b3ba8589f99adbf752fcb..54fd38589674526d24cd68b870ef5c61493b3863 100644 (file)
@@ -1369,7 +1369,7 @@ new_segment:
        } /* segments in rq */
 
        if (sg)
-               __sg_mark_end(sg);
+               sg_mark_end(sg);
 
        return nsegs;
 }
index 61fdaf02f2511fb09aa6008ab5d78b354d39554b..88de771d3569ff7b58fff72a2926d2eaf28b0510 100644 (file)
@@ -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
index d5e1876daf3febe7105646b72b20d74bdbcdcabd..25973504414823b7876d2f34256ea1f103018ddb 100644 (file)
@@ -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]);
 }
 
 /**
index 64b50ff7a41399baeec0d10a44a94e291d9e8607..32d5826b7177078eb51dd99bc1887b974516888f 100644 (file)
@@ -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;
 }
index eec02b29ffcfb7c71483f8e59816a44c528da02c..d438dfb0c8f38a9f53833a6283eb30a40741ff78 100644 (file)
@@ -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);
index 4b9032880959421be4d8e08780f58efd38cdb726..06be2a1f27303d761b63aa0ce5c30da3c253eb65 100644 (file)
@@ -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);
index c387cf68a08c6431ef18ff2bd1df36b7b16e2f44..e09a95aa68ff7acf6cd98cf41947419a51c9f2d4 100644 (file)
@@ -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);
 }
index ab7cbd6575c45d0c860e599cf27202dee5249c57..0dd792338fa96298bb523812e10ff81ebf4a7480 100644 (file)
@@ -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);