diff options
author | Liu Bo <bo.liu@linux.alibaba.com> | 2018-09-13 19:44:42 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-10-15 17:23:31 +0200 |
commit | abb57ef3ff9720c42bbc06bcd1788da9ce1a3eb8 (patch) | |
tree | 3fadcf36a6e3770833520651cfd2141520144e57 /fs/btrfs/extent_io.c | |
parent | Btrfs: assert page dirty bit on extent buffer pages (diff) | |
download | linux-abb57ef3ff9720c42bbc06bcd1788da9ce1a3eb8.tar.xz linux-abb57ef3ff9720c42bbc06bcd1788da9ce1a3eb8.zip |
Btrfs: skip set_page_dirty if eb pages are already dirty
As long as @eb is marked with EXTENT_BUFFER_DIRTY, all of its pages
are dirty, so no need to set pages dirty again.
Ftrace showed that the loop took 10us on my dev box, so removing this
can save us at least 10us if eb is already dirty and otherwise avoid a
potentially expensive calls to set_page_dirty.
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index ce2aa692b444..ba2a13e908a9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5160,11 +5160,11 @@ void clear_extent_buffer_dirty(struct extent_buffer *eb) WARN_ON(atomic_read(&eb->refs) == 0); } -int set_extent_buffer_dirty(struct extent_buffer *eb) +bool set_extent_buffer_dirty(struct extent_buffer *eb) { int i; int num_pages; - int was_dirty = 0; + bool was_dirty; check_buffer_tree_ref(eb); @@ -5174,8 +5174,9 @@ int set_extent_buffer_dirty(struct extent_buffer *eb) WARN_ON(atomic_read(&eb->refs) == 0); WARN_ON(!test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags)); - for (i = 0; i < num_pages; i++) - set_page_dirty(eb->pages[i]); + if (!was_dirty) + for (i = 0; i < num_pages; i++) + set_page_dirty(eb->pages[i]); #ifdef CONFIG_BTRFS_DEBUG for (i = 0; i < num_pages; i++) |