linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] filemap: minor cleanup for filemap_write_and_wait_range
@ 2022-06-27 13:23 Miaohe Lin
  2022-06-28  3:03 ` Matthew Wilcox
  2022-06-28  7:27 ` Muchun Song
  0 siblings, 2 replies; 4+ messages in thread
From: Miaohe Lin @ 2022-06-27 13:23 UTC (permalink / raw)
  To: akpm, willy; +Cc: linux-fsdevel, linux-mm, linux-kernel, linmiaohe

Restructure the logic in filemap_write_and_wait_range to simplify the code
and make it more consistent with file_write_and_wait_range. No functional
change intended.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/filemap.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 8ccb868c3d95..b561619cfafe 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -667,7 +667,7 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback);
 int filemap_write_and_wait_range(struct address_space *mapping,
 				 loff_t lstart, loff_t lend)
 {
-	int err = 0;
+	int err = 0, err2;
 
 	if (mapping_needs_writeback(mapping)) {
 		err = __filemap_fdatawrite_range(mapping, lstart, lend,
@@ -678,18 +678,12 @@ int filemap_write_and_wait_range(struct address_space *mapping,
 		 * But the -EIO is special case, it may indicate the worst
 		 * thing (e.g. bug) happened, so we avoid waiting for it.
 		 */
-		if (err != -EIO) {
-			int err2 = filemap_fdatawait_range(mapping,
-						lstart, lend);
-			if (!err)
-				err = err2;
-		} else {
-			/* Clear any previously stored errors */
-			filemap_check_errors(mapping);
-		}
-	} else {
-		err = filemap_check_errors(mapping);
+		if (err != -EIO)
+			__filemap_fdatawait_range(mapping, lstart, lend);
 	}
+	err2 = filemap_check_errors(mapping);
+	if (!err)
+		err = err2;
 	return err;
 }
 EXPORT_SYMBOL(filemap_write_and_wait_range);
-- 
2.23.0



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

* Re: [PATCH] filemap: minor cleanup for filemap_write_and_wait_range
  2022-06-27 13:23 [PATCH] filemap: minor cleanup for filemap_write_and_wait_range Miaohe Lin
@ 2022-06-28  3:03 ` Matthew Wilcox
  2022-06-28  3:20   ` Miaohe Lin
  2022-06-28  7:27 ` Muchun Song
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2022-06-28  3:03 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, linux-fsdevel, linux-mm, linux-kernel

On Mon, Jun 27, 2022 at 09:23:51PM +0800, Miaohe Lin wrote:
> Restructure the logic in filemap_write_and_wait_range to simplify the code
> and make it more consistent with file_write_and_wait_range. No functional
> change intended.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Looks OK to me at a quick glance.  I'll look at it more closely next
week when I'm back from holiday.


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

* Re: [PATCH] filemap: minor cleanup for filemap_write_and_wait_range
  2022-06-28  3:03 ` Matthew Wilcox
@ 2022-06-28  3:20   ` Miaohe Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaohe Lin @ 2022-06-28  3:20 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: akpm, linux-fsdevel, linux-mm, linux-kernel

On 2022/6/28 11:03, Matthew Wilcox wrote:
> On Mon, Jun 27, 2022 at 09:23:51PM +0800, Miaohe Lin wrote:
>> Restructure the logic in filemap_write_and_wait_range to simplify the code
>> and make it more consistent with file_write_and_wait_range. No functional
>> change intended.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> 
> Looks OK to me at a quick glance.  I'll look at it more closely next
> week when I'm back from holiday.

Thanks for your time. Enjoy your holiday. ;)

> 
> .
> 



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

* Re: [PATCH] filemap: minor cleanup for filemap_write_and_wait_range
  2022-06-27 13:23 [PATCH] filemap: minor cleanup for filemap_write_and_wait_range Miaohe Lin
  2022-06-28  3:03 ` Matthew Wilcox
@ 2022-06-28  7:27 ` Muchun Song
  1 sibling, 0 replies; 4+ messages in thread
From: Muchun Song @ 2022-06-28  7:27 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, willy, linux-fsdevel, linux-mm, linux-kernel

On Mon, Jun 27, 2022 at 09:23:51PM +0800, Miaohe Lin wrote:
> Restructure the logic in filemap_write_and_wait_range to simplify the code
> and make it more consistent with file_write_and_wait_range. No functional
> change intended.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.


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

end of thread, other threads:[~2022-06-28  7:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 13:23 [PATCH] filemap: minor cleanup for filemap_write_and_wait_range Miaohe Lin
2022-06-28  3:03 ` Matthew Wilcox
2022-06-28  3:20   ` Miaohe Lin
2022-06-28  7:27 ` Muchun Song

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