Skip to contentSkip to conversation

cifs: get rid of unneeded conditional in cifs_get_num_sgs()

PATCH In review Paulo Alcantara 2 participants 2 messages Jan 31, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: get rid of unneeded conditional in cifs_get_num_sgs()

Just have @skip set to 0 after first iterations of the two nested loops.

---
 fs/cifs/cifsglob.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/cifs/cifsglob.h +7 -5
index 3da302ea9d76..1d893bea4723 100644
@@ -2164,6 +2164,12 @@ static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
 	unsigned long addr;
 	int i, j;
 
+	/*
+	 * The first rqst has a transform header where the first 20 bytes are
+	 * not part of the encrypted blob.
+	 */
+	skip = 20;
+
 	/* Assumes the first rqst has a transform header as the first iov.
 	 * I.e.
 	 * rqst[0].rq_iov[0]  is transform header
@@ -2171,14 +2177,9 @@ static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
 	 * rqst[1+].rq_iov[0+] data to be encrypted/decrypted
 	 */
 	for (i = 0; i < num_rqst; i++) {
-		/*
-		 * The first rqst has a transform header where the
-		 * first 20 bytes are not part of the encrypted blob.
-		 */
 		for (j = 0; j < rqst[i].rq_nvec; j++) {
 			struct kvec *iov = &rqst[i].rq_iov[j];
 
-			skip = (i == 0) && (j == 0) ? 20 : 0;
 			addr = (unsigned long)iov->iov_base + skip;
 			if (unlikely(is_vmalloc_addr((void *)addr))) {
 				len = iov->iov_len - skip;
@@ -2187,6 +2188,7 @@ static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
 			} else {
 				nents++;
 			}
+			skip = 0;
 		}
 		nents += rqst[i].rq_npages;
 	}
Signature · 1 line
2.39.1
#1 lore raw

added David Howell's RGB and tentatively posted to cifs-2.6.git for-next pending testing

Quoted 52 lines · Paulo Alcantara

Just have @skip set to 0 after first iterations of the two nested loops.

---
 fs/cifs/cifsglob.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/cifs/cifsglob.h +7 -6
index 3da302ea9d76..1d893bea4723 100644
@@ -2164,6 +2164,12 @@ static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
        unsigned long addr;
        int i, j;
 
+       /*
+        * The first rqst has a transform header where the first 20 bytes are
+        * not part of the encrypted blob.
+        */
+       skip = 20;
+
        /* Assumes the first rqst has a transform header as the first iov.
         * I.e.
         * rqst[0].rq_iov[0]  is transform header
@@ -2171,14 +2177,9 @@ static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
         * rqst[1+].rq_iov[0+] data to be encrypted/decrypted
         */
        for (i = 0; i < num_rqst; i++) {
-               /*
-                * The first rqst has a transform header where the
-                * first 20 bytes are not part of the encrypted blob.
-                */
                for (j = 0; j < rqst[i].rq_nvec; j++) {
                        struct kvec *iov = &rqst[i].rq_iov[j];
 
-                       skip = (i == 0) && (j == 0) ? 20 : 0;
                        addr = (unsigned long)iov->iov_base + skip;
                        if (unlikely(is_vmalloc_addr((void *)addr))) {
                                len = iov->iov_len - skip;
@@ -2187,6 +2188,7 @@ static inline unsigned int cifs_get_num_sgs(const struct smb_rqst *rqst,
                        } else {
                                nents++;
                        }
+                       skip = 0;
                }
                nents += rqst[i].rq_npages;
        }
--

2.39.1

Signature · 3 lines
Thanks,

Steve