Commit 5a3d5c9813db56a75934eb1015367fda23a8b0b4
Committed by
Linus Torvalds
1 parent
05fe478dd0
Exists in
master
and in
20 other branches
mm: write_cache_pages cleanups
Get rid of some complex expressions from flow control statements, add a comment, remove some duplicate code. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: Chris Mason <chris.mason@oracle.com> Cc: Dave Chinner <david@fromorbit.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 22 additions and 12 deletions Side-by-side Diff
mm/page-writeback.c
... | ... | @@ -899,12 +899,15 @@ |
899 | 899 | } |
900 | 900 | retry: |
901 | 901 | done_index = index; |
902 | - while (!done && (index <= end) && | |
903 | - (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, | |
904 | - PAGECACHE_TAG_DIRTY, | |
905 | - min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) { | |
906 | - unsigned i; | |
902 | + while (!done && (index <= end)) { | |
903 | + int i; | |
907 | 904 | |
905 | + nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, | |
906 | + PAGECACHE_TAG_DIRTY, | |
907 | + min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1); | |
908 | + if (nr_pages == 0) | |
909 | + break; | |
910 | + | |
908 | 911 | for (i = 0; i < nr_pages; i++) { |
909 | 912 | struct page *page = pvec.pages[i]; |
910 | 913 | |
911 | 914 | |
... | ... | @@ -919,7 +922,16 @@ |
919 | 922 | */ |
920 | 923 | lock_page(page); |
921 | 924 | |
925 | + /* | |
926 | + * Page truncated or invalidated. We can freely skip it | |
927 | + * then, even for data integrity operations: the page | |
928 | + * has disappeared concurrently, so there could be no | |
929 | + * real expectation of this data interity operation | |
930 | + * even if there is now a new, dirty page at the same | |
931 | + * pagecache address. | |
932 | + */ | |
922 | 933 | if (unlikely(page->mapping != mapping)) { |
934 | +continue_unlock: | |
923 | 935 | unlock_page(page); |
924 | 936 | continue; |
925 | 937 | } |
926 | 938 | |
... | ... | @@ -930,18 +942,15 @@ |
930 | 942 | * end == -1 in that case. |
931 | 943 | */ |
932 | 944 | done = 1; |
933 | - unlock_page(page); | |
934 | - continue; | |
945 | + goto continue_unlock; | |
935 | 946 | } |
936 | 947 | |
937 | 948 | if (wbc->sync_mode != WB_SYNC_NONE) |
938 | 949 | wait_on_page_writeback(page); |
939 | 950 | |
940 | 951 | if (PageWriteback(page) || |
941 | - !clear_page_dirty_for_io(page)) { | |
942 | - unlock_page(page); | |
943 | - continue; | |
944 | - } | |
952 | + !clear_page_dirty_for_io(page)) | |
953 | + goto continue_unlock; | |
945 | 954 | |
946 | 955 | ret = (*writepage)(page, wbc, data); |
947 | 956 | if (unlikely(ret)) { |
... | ... | @@ -964,7 +973,8 @@ |
964 | 973 | } |
965 | 974 | |
966 | 975 | if (wbc->sync_mode == WB_SYNC_NONE) { |
967 | - if (--wbc->nr_to_write <= 0) | |
976 | + wbc->nr_to_write--; | |
977 | + if (wbc->nr_to_write <= 0) | |
968 | 978 | done = 1; |
969 | 979 | } |
970 | 980 | if (wbc->nonblocking && bdi_write_congested(bdi)) { |