public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Cleanups for extent_page_data
@ 2017-12-07 15:47 David Sterba
  2017-12-07 15:47 ` [PATCH 1/4] btrfs: merge two flush_write_bio helpers David Sterba
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Sterba @ 2017-12-07 15:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

David Sterba (4):
  btrfs: merge two flush_write_bio helpers
  btrfs: sink flush_fn to extent_write_cache_pages
  btrfs: sink writepage parameter to extent_write_cache_pages
  btrfs: unify extent_page_data type passed as void

 fs/btrfs/extent_io.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

-- 
2.15.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] btrfs: merge two flush_write_bio helpers
  2017-12-07 15:47 [PATCH 0/4] Cleanups for extent_page_data David Sterba
@ 2017-12-07 15:47 ` David Sterba
  2017-12-07 15:47 ` [PATCH 2/4] btrfs: sink flush_fn to extent_write_cache_pages David Sterba
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2017-12-07 15:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

flush_epd_write_bio is same as flush_write_bio, no point having two such
functions. Merge them to flush_write_bio. The 'noinline' attribute is
removed as it does not have any meaning.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 16ae832bdb5d..fd1a2ff1e96d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -138,7 +138,8 @@ static void add_extent_changeset(struct extent_state *state, unsigned bits,
 	BUG_ON(ret < 0);
 }
 
-static noinline void flush_write_bio(void *data);
+static void flush_write_bio(void *data);
+
 static inline struct btrfs_fs_info *
 tree_fs_info(struct extent_io_tree *tree)
 {
@@ -4039,8 +4040,10 @@ static int extent_write_cache_pages(struct address_space *mapping,
 	return ret;
 }
 
-static void flush_epd_write_bio(struct extent_page_data *epd)
+static void flush_write_bio(void *data)
 {
+	struct extent_page_data *epd = data;
+
 	if (epd->bio) {
 		int ret;
 
@@ -4050,12 +4053,6 @@ static void flush_epd_write_bio(struct extent_page_data *epd)
 	}
 }
 
-static noinline void flush_write_bio(void *data)
-{
-	struct extent_page_data *epd = data;
-	flush_epd_write_bio(epd);
-}
-
 int extent_write_full_page(struct extent_io_tree *tree, struct page *page,
 			  struct writeback_control *wbc)
 {
@@ -4069,7 +4066,7 @@ int extent_write_full_page(struct extent_io_tree *tree, struct page *page,
 
 	ret = __extent_writepage(page, wbc, &epd);
 
-	flush_epd_write_bio(&epd);
+	flush_write_bio(&epd);
 	return ret;
 }
 
@@ -4110,7 +4107,7 @@ int extent_write_locked_range(struct extent_io_tree *tree, struct inode *inode,
 		start += PAGE_SIZE;
 	}
 
-	flush_epd_write_bio(&epd);
+	flush_write_bio(&epd);
 	return ret;
 }
 
@@ -4128,7 +4125,7 @@ int extent_writepages(struct extent_io_tree *tree,
 
 	ret = extent_write_cache_pages(mapping, wbc, __extent_writepage, &epd,
 				       flush_write_bio);
-	flush_epd_write_bio(&epd);
+	flush_write_bio(&epd);
 	return ret;
 }
 
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] btrfs: sink flush_fn to extent_write_cache_pages
  2017-12-07 15:47 [PATCH 0/4] Cleanups for extent_page_data David Sterba
  2017-12-07 15:47 ` [PATCH 1/4] btrfs: merge two flush_write_bio helpers David Sterba
@ 2017-12-07 15:47 ` David Sterba
  2017-12-07 15:47 ` [PATCH 3/4] btrfs: sink writepage parameter " David Sterba
  2017-12-07 15:47 ` [PATCH 4/4] btrfs: unify extent_page_data type passed as void David Sterba
  3 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2017-12-07 15:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

All callers pass the same value flush_write_bio.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fd1a2ff1e96d..35f4869a90d5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3906,8 +3906,7 @@ int btree_write_cache_pages(struct address_space *mapping,
  */
 static int extent_write_cache_pages(struct address_space *mapping,
 			     struct writeback_control *wbc,
-			     writepage_t writepage, void *data,
-			     void (*flush_fn)(void *))
+			     writepage_t writepage, void *data)
 {
 	struct inode *inode = mapping->host;
 	int ret = 0;
@@ -3971,7 +3970,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 			 * mapping
 			 */
 			if (!trylock_page(page)) {
-				flush_fn(data);
+				flush_write_bio(data);
 				lock_page(page);
 			}
 
@@ -3982,7 +3981,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 
 			if (wbc->sync_mode != WB_SYNC_NONE) {
 				if (PageWriteback(page))
-					flush_fn(data);
+					flush_write_bio(data);
 				wait_on_page_writeback(page);
 			}
 
@@ -4123,8 +4122,7 @@ int extent_writepages(struct extent_io_tree *tree,
 		.sync_io = wbc->sync_mode == WB_SYNC_ALL,
 	};
 
-	ret = extent_write_cache_pages(mapping, wbc, __extent_writepage, &epd,
-				       flush_write_bio);
+	ret = extent_write_cache_pages(mapping, wbc, __extent_writepage, &epd);
 	flush_write_bio(&epd);
 	return ret;
 }
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] btrfs: sink writepage parameter to extent_write_cache_pages
  2017-12-07 15:47 [PATCH 0/4] Cleanups for extent_page_data David Sterba
  2017-12-07 15:47 ` [PATCH 1/4] btrfs: merge two flush_write_bio helpers David Sterba
  2017-12-07 15:47 ` [PATCH 2/4] btrfs: sink flush_fn to extent_write_cache_pages David Sterba
@ 2017-12-07 15:47 ` David Sterba
  2017-12-07 15:47 ` [PATCH 4/4] btrfs: unify extent_page_data type passed as void David Sterba
  3 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2017-12-07 15:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function extent_write_cache_pages is modelled after
write_cache_pages which is a generic interface and the writepage
parameter makes sense there. In btrfs we know exactly which callback
we're going to use, so we can pass it directly.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 35f4869a90d5..47435256a8c3 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3893,8 +3893,7 @@ int btree_write_cache_pages(struct address_space *mapping,
  * write_cache_pages - walk the list of dirty pages of the given address space and write all of them.
  * @mapping: address space structure to write
  * @wbc: subtract the number of written pages from *@wbc->nr_to_write
- * @writepage: function called for each page
- * @data: data passed to writepage function
+ * @data: data passed to __extent_writepage function
  *
  * If a page is already under I/O, write_cache_pages() skips it, even
  * if it's dirty.  This is desirable behaviour for memory-cleaning writeback,
@@ -3906,7 +3905,7 @@ int btree_write_cache_pages(struct address_space *mapping,
  */
 static int extent_write_cache_pages(struct address_space *mapping,
 			     struct writeback_control *wbc,
-			     writepage_t writepage, void *data)
+			     void *data)
 {
 	struct inode *inode = mapping->host;
 	int ret = 0;
@@ -3991,7 +3990,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 				continue;
 			}
 
-			ret = (*writepage)(page, wbc, data);
+			ret = __extent_writepage(page, wbc, data);
 
 			if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE)) {
 				unlock_page(page);
@@ -4122,7 +4121,7 @@ int extent_writepages(struct extent_io_tree *tree,
 		.sync_io = wbc->sync_mode == WB_SYNC_ALL,
 	};
 
-	ret = extent_write_cache_pages(mapping, wbc, __extent_writepage, &epd);
+	ret = extent_write_cache_pages(mapping, wbc, &epd);
 	flush_write_bio(&epd);
 	return ret;
 }
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] btrfs: unify extent_page_data type passed as void
  2017-12-07 15:47 [PATCH 0/4] Cleanups for extent_page_data David Sterba
                   ` (2 preceding siblings ...)
  2017-12-07 15:47 ` [PATCH 3/4] btrfs: sink writepage parameter " David Sterba
@ 2017-12-07 15:47 ` David Sterba
  3 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2017-12-07 15:47 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Functions called from extent_write_cache_pages used void* as generic
callback data, but all of them convert it to extent_page_data, or use it
directly.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 47435256a8c3..6cfb25c30a2d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -138,7 +138,7 @@ static void add_extent_changeset(struct extent_state *state, unsigned bits,
 	BUG_ON(ret < 0);
 }
 
-static void flush_write_bio(void *data);
+static void flush_write_bio(struct extent_page_data *epd);
 
 static inline struct btrfs_fs_info *
 tree_fs_info(struct extent_io_tree *tree)
@@ -3456,10 +3456,9 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode,
  * and the end_io handler clears the writeback ranges
  */
 static int __extent_writepage(struct page *page, struct writeback_control *wbc,
-			      void *data)
+			      struct extent_page_data *epd)
 {
 	struct inode *inode = page->mapping->host;
-	struct extent_page_data *epd = data;
 	u64 start = page_offset(page);
 	u64 page_end = start + PAGE_SIZE - 1;
 	int ret;
@@ -3905,7 +3904,7 @@ int btree_write_cache_pages(struct address_space *mapping,
  */
 static int extent_write_cache_pages(struct address_space *mapping,
 			     struct writeback_control *wbc,
-			     void *data)
+			     struct extent_page_data *epd)
 {
 	struct inode *inode = mapping->host;
 	int ret = 0;
@@ -3969,7 +3968,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 			 * mapping
 			 */
 			if (!trylock_page(page)) {
-				flush_write_bio(data);
+				flush_write_bio(epd);
 				lock_page(page);
 			}
 
@@ -3980,7 +3979,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 
 			if (wbc->sync_mode != WB_SYNC_NONE) {
 				if (PageWriteback(page))
-					flush_write_bio(data);
+					flush_write_bio(epd);
 				wait_on_page_writeback(page);
 			}
 
@@ -3990,7 +3989,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 				continue;
 			}
 
-			ret = __extent_writepage(page, wbc, data);
+			ret = __extent_writepage(page, wbc, epd);
 
 			if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE)) {
 				unlock_page(page);
@@ -4038,10 +4037,8 @@ static int extent_write_cache_pages(struct address_space *mapping,
 	return ret;
 }
 
-static void flush_write_bio(void *data)
+static void flush_write_bio(struct extent_page_data *epd)
 {
-	struct extent_page_data *epd = data;
-
 	if (epd->bio) {
 		int ret;
 
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-07 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-07 15:47 [PATCH 0/4] Cleanups for extent_page_data David Sterba
2017-12-07 15:47 ` [PATCH 1/4] btrfs: merge two flush_write_bio helpers David Sterba
2017-12-07 15:47 ` [PATCH 2/4] btrfs: sink flush_fn to extent_write_cache_pages David Sterba
2017-12-07 15:47 ` [PATCH 3/4] btrfs: sink writepage parameter " David Sterba
2017-12-07 15:47 ` [PATCH 4/4] btrfs: unify extent_page_data type passed as void David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox