Skip to contentSkip to conversation

ceph: refactor readpage_nounlock() to make the logic clearer

PATCH In review Zhang Zhen 3 participants 3 messages May 28, 2014 1 message not in the archive Ceph client

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Zhang Zhen

author
#1 lore raw

PATCH 1/1 ceph: refactor readpage_nounlock() to make the logic clearer

If the return value of ceph_osdc_readpages() is not negative, it is certainly greater than or equal to zero.

Remove the useless condition judgment and redundant braces.

---
 fs/ceph/addr.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
fs/ceph/addr.c +7 -10
index b53278c..6aa2e3f 100644
@@ -211,18 +211,15 @@ static int readpage_nounlock(struct file *filp, struct page *page)
 		SetPageError(page);
 		ceph_fscache_readpage_cancel(inode, page);
 		goto out;
-	} else {
-		if (err < PAGE_CACHE_SIZE) {
-		/* zero fill remainder of page */
-			zero_user_segment(page, err, PAGE_CACHE_SIZE);
-		} else {
-			flush_dcache_page(page);
-		}
 	}
-	SetPageUptodate(page);
+	if (err < PAGE_CACHE_SIZE)
+		/* zero fill remainder of page */
+		zero_user_segment(page, err, PAGE_CACHE_SIZE);
+	else
+		flush_dcache_page(page);
 
-	if (err >= 0)
-		ceph_readpage_to_fscache(inode, page);
+	SetPageUptodate(page);
+	ceph_readpage_to_fscache(inode, page);
 
 out:
 	return err < 0 ? err : 0;
Signature · 4 lines
1.8.1.2


.
#2 lore raw
Quoted 31 lines · Zhang Zhen

If the return value of ceph_osdc_readpages() is not negative, it is certainly greater than or equal to zero.

Remove the useless condition judgment and redundant braces.

---
 fs/ceph/addr.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
fs/ceph/addr.c +4 -8
index b53278c..6aa2e3f 100644
@@ -211,18 +211,15 @@ static int readpage_nounlock(struct file *filp, struct page *page)
                SetPageError(page);
                ceph_fscache_readpage_cancel(inode, page);
                goto out;
-       } else {
-               if (err < PAGE_CACHE_SIZE) {
-               /* zero fill remainder of page */
-                       zero_user_segment(page, err, PAGE_CACHE_SIZE);
-               } else {
-                       flush_dcache_page(page);
-               }
        }
-       SetPageUptodate(page);
+       if (err < PAGE_CACHE_SIZE)
+               /* zero fill remainder of page */
+               zero_user_segment(page, err, PAGE_CACHE_SIZE);
+       else

fs/ceph/addr.c static int readpage_nounlock(struct file *filp, struct page *page)

Quoted 10 lines
fs/ceph/addr.c +3 -3
+               flush_dcache_page(page);
 
-       if (err >= 0)
-               ceph_readpage_to_fscache(inode, page);
+       SetPageUptodate(page);
+       ceph_readpage_to_fscache(inode, page);
 
 out:
        return err < 0 ? err : 0;
--

Added to testing branch of ceph-client

Thanks
Yan, Zheng

Quoted 8 lines

1.8.1.2

.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Zhang Zhen
Quoted 6 lines · Zhang Zhen

If the return value of ceph_osdc_readpages() is not negative, it is certainly greater than or equal to zero.

Remove the useless condition judgment and redundant braces.

This looks good.

Quoted 35 lines
---
 fs/ceph/addr.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
fs/ceph/addr.c +7 -10
index b53278c..6aa2e3f 100644
@@ -211,18 +211,15 @@ static int readpage_nounlock(struct file *filp, struct page *page)
 		SetPageError(page);
 		ceph_fscache_readpage_cancel(inode, page);
 		goto out;
-	} else {
-		if (err < PAGE_CACHE_SIZE) {
-		/* zero fill remainder of page */
-			zero_user_segment(page, err, PAGE_CACHE_SIZE);
-		} else {
-			flush_dcache_page(page);
-		}
 	}
-	SetPageUptodate(page);
+	if (err < PAGE_CACHE_SIZE)
+		/* zero fill remainder of page */
+		zero_user_segment(page, err, PAGE_CACHE_SIZE);
+	else
+		flush_dcache_page(page);
 
-	if (err >= 0)
-		ceph_readpage_to_fscache(inode, page);
+	SetPageUptodate(page);
+	ceph_readpage_to_fscache(inode, page);
 
 out:
 	return err < 0 ? err : 0;