diff mbox

ceph: sync metadata when having I_DIRTY_DATASYNC flag in fdatasync

Message ID 1520669899-239998-1-git-send-email-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chengguang Xu March 10, 2018, 8:18 a.m. UTC
When inode marks flag I_DIRTY_DATASYNC, even if fdatasync
should sync essential metadata.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/ceph/caps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yan, Zheng March 12, 2018, 3:40 a.m. UTC | #1
On Sat, Mar 10, 2018 at 4:18 PM, Chengguang Xu <cgxu519@gmx.com> wrote:
> When inode marks flag I_DIRTY_DATASYNC, even if fdatasync
> should sync essential metadata.
>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>  fs/ceph/caps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 0e5bd3e..6e08abb 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -2170,7 +2170,7 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
>         if (ret < 0)
>                 goto out;
>
> -       if (datasync)
> +       if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
>                 goto out;
>
>         inode_lock(inode);

The code in __ceph_mark_dirty_caps() that set I_DIRTY_DATASYNC should
never be executed.  we never mark CEPH_CAP_FILE_BUFFER dirty. need
check if that's a bug first

> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chengguang Xu March 12, 2018, 4:05 a.m. UTC | #2
> Sent: Monday, March 12, 2018 at 11:40 AM
> From: "Yan, Zheng" <ukernel@gmail.com>
> To: "Chengguang Xu" <cgxu519@gmx.com>
> Cc: "Zheng Yan" <zyan@redhat.com>, "Ilya Dryomov" <idryomov@gmail.com>, ceph-devel <ceph-devel@vger.kernel.org>
> Subject: Re: [PATCH] ceph: sync metadata when having I_DIRTY_DATASYNC flag in fdatasync
>
> On Sat, Mar 10, 2018 at 4:18 PM, Chengguang Xu <cgxu519@gmx.com> wrote:
> > When inode marks flag I_DIRTY_DATASYNC, even if fdatasync
> > should sync essential metadata.
> >
> > Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> > ---
> >  fs/ceph/caps.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> > index 0e5bd3e..6e08abb 100644
> > --- a/fs/ceph/caps.c
> > +++ b/fs/ceph/caps.c
> > @@ -2170,7 +2170,7 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
> >         if (ret < 0)
> >                 goto out;
> >
> > -       if (datasync)
> > +       if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
> >                 goto out;
> >
> >         inode_lock(inode);
> 
> The code in __ceph_mark_dirty_caps() that set I_DIRTY_DATASYNC should
> never be executed.  we never mark CEPH_CAP_FILE_BUFFER dirty. need
> check if that's a bug first

Hi Yan,

Thanks for your review.

I checked the calling places yesterday and there is no place to mark CEPH_CAP_FILE_BUFFER dirty
in current code, so if no chance to mark that in the future, then we can delete the related logic
in the __ceph_mark_dirty_caps().

I add another flag check in revised version of this patch, could you have a quick look at that part?


Thanks,
Chengguang.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0e5bd3e..6e08abb 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2170,7 +2170,7 @@  int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 	if (ret < 0)
 		goto out;
 
-	if (datasync)
+	if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
 		goto out;
 
 	inode_lock(inode);