[RFC,4/5] orangefs: call __clear_page_buffers to simplify code
diff mbox series

Message ID 20200418225123.31850-5-guoqing.jiang@cloud.ionos.com
State New
Headers show
Series
  • export __clear_page_buffers to cleanup code
Related show

Commit Message

Guoqing Jiang April 18, 2020, 10:51 p.m. UTC
Since __clear_page_buffers is exported, we can call __clear_page_buffers
to simplify code in the four places.

Cc: Mike Marshall <hubcap@omnibond.com>
Cc: Martin Brandenburg <martin@omnibond.com>
Cc: devel@lists.orangefs.org
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
The order for set_page_private and ClearPagePrivate is swapped in
__clear_page_buffers, not sure it is identical or not, so this is
RFC.

Thanks,
Guoqing

 fs/orangefs/inode.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 12ae630fbed7..8e1591d8bf24 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -11,6 +11,7 @@ 
  */
 
 #include <linux/bvec.h>
+#include <linux/buffer_head.h>
 #include "protocol.h"
 #include "orangefs-kernel.h"
 #include "orangefs-bufmap.h"
@@ -64,9 +65,7 @@  static int orangefs_writepage_locked(struct page *page,
 	}
 	if (wr) {
 		kfree(wr);
-		set_page_private(page, 0);
-		ClearPagePrivate(page);
-		put_page(page);
+		__clear_page_buffers(page);
 	}
 	return ret;
 }
@@ -460,17 +459,13 @@  static void orangefs_invalidatepage(struct page *page,
 
 	if (offset == 0 && length == PAGE_SIZE) {
 		kfree((struct orangefs_write_range *)page_private(page));
-		set_page_private(page, 0);
-		ClearPagePrivate(page);
-		put_page(page);
+		__clear_page_buffers(page);
 		return;
 	/* write range entirely within invalidate range (or equal) */
 	} else if (page_offset(page) + offset <= wr->pos &&
 	    wr->pos + wr->len <= page_offset(page) + offset + length) {
 		kfree((struct orangefs_write_range *)page_private(page));
-		set_page_private(page, 0);
-		ClearPagePrivate(page);
-		put_page(page);
+		__clear_page_buffers(page);
 		/* XXX is this right? only caller in fs */
 		cancel_dirty_page(page);
 		return;
@@ -537,9 +532,7 @@  static void orangefs_freepage(struct page *page)
 {
 	if (PagePrivate(page)) {
 		kfree((struct orangefs_write_range *)page_private(page));
-		set_page_private(page, 0);
-		ClearPagePrivate(page);
-		put_page(page);
+		__clear_page_buffers(page);
 	}
 }