From: akpm@linux-foundation.org Subject: + fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage.patch added to -mm tree Date: Thu, 24 Apr 2014 11:17:58 -0700 Message-ID: <53595556.i759dfQgkWsRJ1s9%akpm@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:38224 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758790AbaDXSR7 (ORCPT ); Thu, 24 Apr 2014 14:17:59 -0400 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: mm-commits@vger.kernel.org, hughd@google.com, dheeraj.reddy@intel.com, david@fromorbit.com, matthew.r.wilcox@intel.com Subject: + fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage.patch added to -mm tree To: matthew.r.wilcox@intel.com,david@fromorbit.com,dheeraj.reddy@intel.com,hughd@google.com From: akpm@linux-foundation.org Date: Thu, 24 Apr 2014 11:17:58 -0700 The patch titled Subject: fs/mpage.c: factor clean_buffers() out of __mpage_writepage() has been added to the -mm tree. Its filename is fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Matthew Wilcox Subject: fs/mpage.c: factor clean_buffers() out of __mpage_writepage() __mpage_writepage() is over 200 lines long, has 20 local variables, four goto labels and could desperately use simplification. Splitting clean_buffers() into a helper function improves matters a little, removing 20+ lines from it. Signed-off-by: Matthew Wilcox Cc: Dave Chinner Cc: Dheeraj Reddy Cc: Hugh Dickins Signed-off-by: Andrew Morton --- fs/mpage.c | 54 ++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff -puN fs/mpage.c~fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage fs/mpage.c --- a/fs/mpage.c~fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage +++ a/fs/mpage.c @@ -439,6 +439,35 @@ struct mpage_data { unsigned use_writepage; }; +/* + * We have our BIO, so we can now mark the buffers clean. Make + * sure to only clean buffers which we know we'll be writing. + */ +static void clean_buffers(struct page *page, unsigned first_unmapped) +{ + unsigned buffer_counter = 0; + struct buffer_head *bh, *head; + if (!page_has_buffers(page)) + return; + head = page_buffers(page); + bh = head; + + do { + if (buffer_counter++ == first_unmapped) + break; + clear_buffer_dirty(bh); + bh = bh->b_this_page; + } while (bh != head); + + /* + * we cannot drop the bh if the page is not uptodate or a concurrent + * readpage would fail to serialize with the bh and it would read from + * disk before we reach the platter. + */ + if (buffer_heads_over_limit && PageUptodate(page)) + try_to_free_buffers(page); +} + static int __mpage_writepage(struct page *page, struct writeback_control *wbc, void *data) { @@ -592,30 +621,7 @@ alloc_new: goto alloc_new; } - /* - * OK, we have our BIO, so we can now mark the buffers clean. Make - * sure to only clean buffers which we know we'll be writing. - */ - if (page_has_buffers(page)) { - struct buffer_head *head = page_buffers(page); - struct buffer_head *bh = head; - unsigned buffer_counter = 0; - - do { - if (buffer_counter++ == first_unmapped) - break; - clear_buffer_dirty(bh); - bh = bh->b_this_page; - } while (bh != head); - - /* - * we cannot drop the bh if the page is not uptodate - * or a concurrent readpage would fail to serialize with the bh - * and it would read from disk before we reach the platter. - */ - if (buffer_heads_over_limit && PageUptodate(page)) - try_to_free_buffers(page); - } + clean_buffers(page, first_unmapped); BUG_ON(PageWriteback(page)); set_page_writeback(page); _ Patches currently in -mm which might be from matthew.r.wilcox@intel.com are origin.patch mm-introduce-do_shared_fault-and-drop-do_fault-fix-fix.patch fs-bufferc-remove-block_write_full_page_endio.patch fs-mpagec-factor-clean_buffers-out-of-__mpage_writepage.patch fs-mpagec-factor-page_endio-out-of-mpage_end_io.patch fs-block_devc-add-bdev_read_page-and-bdev_write_page.patch swap-use-bdev_read_page-bdev_write_page.patch brd-add-support-for-rw_page.patch brd-return-enospc-rather-than-enomem-on-page-allocation-failure.patch do_shared_fault-check-that-mmap_sem-is-held.patch linux-next.patch