2021-12-20 02:19:34

by [email protected]

[permalink] [raw]
Subject: [PATCH] exfat: fix missing REQ_SYNC in exfat_update_bhs()

If 'dirsync' is enabled, all directory updates within the
filesystem should be done synchronously. exfat_update_bh()
does as this, but exfat_update_bhs() does not.

Signed-off-by: Yuezhang.Mo <[email protected]>
Reviewed-by: Andy.Wu <[email protected]>
Reviewed-by: Aoyama, Wataru <[email protected]>
Reviewed-by: Kobayashi, Kento <[email protected]>
---
fs/exfat/misc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
index d34e6193258d..d5bd8e6d9741 100644
--- a/fs/exfat/misc.c
+++ b/fs/exfat/misc.c
@@ -10,6 +10,7 @@
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/buffer_head.h>
+#include <linux/blk_types.h>

#include "exfat_raw.h"
#include "exfat_fs.h"
@@ -180,7 +181,7 @@ int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync)
set_buffer_uptodate(bhs[i]);
mark_buffer_dirty(bhs[i]);
if (sync)
- write_dirty_buffer(bhs[i], 0);
+ write_dirty_buffer(bhs[i], REQ_SYNC);
}

for (i = 0; i < nr_bhs && sync; i++) {
--
2.25.1


Attachments:
0001-exfat-fix-missing-REQ_SYNC-in-exfat_update_bhs.patch (1.24 kB)
0001-exfat-fix-missing-REQ_SYNC-in-exfat_update_bhs.patch

2021-12-21 11:57:04

by Namjae Jeon

[permalink] [raw]
Subject: Re: [PATCH] exfat: fix missing REQ_SYNC in exfat_update_bhs()

2021-12-20 10:52 GMT+09:00, [email protected] <[email protected]>:
> If 'dirsync' is enabled, all directory updates within the
> filesystem should be done synchronously. exfat_update_bh()
> does as this, but exfat_update_bhs() does not.
>
> Signed-off-by: Yuezhang.Mo <[email protected]>
> Reviewed-by: Andy.Wu <[email protected]>
> Reviewed-by: Aoyama, Wataru <[email protected]>
> Reviewed-by: Kobayashi, Kento <[email protected]>
Applied, Thanks for your patch.

2021-12-21 12:35:05

by Sungjong Seo

[permalink] [raw]
Subject: RE: [PATCH] exfat: fix missing REQ_SYNC in exfat_update_bhs()

> If 'dirsync' is enabled, all directory updates within the
> filesystem should be done synchronously. exfat_update_bh()
> does as this, but exfat_update_bhs() does not.
>
> Signed-off-by: Yuezhang.Mo <[email protected]>
> Reviewed-by: Andy.Wu <[email protected]>
> Reviewed-by: Aoyama, Wataru <[email protected]>
> Reviewed-by: Kobayashi, Kento <[email protected]>
> ---
> fs/exfat/misc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
> index d34e6193258d..d5bd8e6d9741 100644
> --- a/fs/exfat/misc.c
> +++ b/fs/exfat/misc.c
> @@ -10,6 +10,7 @@
> #include <linux/fs.h>
> #include <linux/slab.h>
> #include <linux/buffer_head.h>
> +#include <linux/blk_types.h>
>
> #include "exfat_raw.h"
> #include "exfat_fs.h"
> @@ -180,7 +181,7 @@ int exfat_update_bhs(struct buffer_head **bhs, int
> nr_bhs, int sync)
> set_buffer_uptodate(bhs[i]);
> mark_buffer_dirty(bhs[i]);
> if (sync)
> - write_dirty_buffer(bhs[i], 0);
> + write_dirty_buffer(bhs[i], REQ_SYNC);

I think there is no problem in terms of functionality related to
"synchronously" in the original code. However, REQ_SYNC could affect
I/O scheduling, and exfat_update_bh() already requests I/O with this
flag by calling sync_dirty_buffer(). And it is desirable for two
functions to have the same concept for I/O requests.

So, the original code does not seem like a bug,
but this patch looks useful.
Thanks.

Reviewed-by: Sungjong Seo <[email protected]>

> }
>
> for (i = 0; i < nr_bhs && sync; i++) {
> --
> 2.25.1