Since __clear_page_buffers is exported, we can call __clear_page_buffers to simplify code in the four places. Cc: Mike Marshall <hubcap@xxxxxxxxxxxx> Cc: Martin Brandenburg <martin@xxxxxxxxxxxx> Cc: devel@xxxxxxxxxxxxxxxxxx Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> --- 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(-) 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); } } -- 2.17.1