Message ID | 20180507083807.28792-16-mszeredi@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, May 7, 2018 at 11:37 AM, Miklos Szeredi <mszeredi@redhat.com> wrote: > Implement stacked fsync(). > > Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> > --- > fs/overlayfs/file.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c > index a7af56861aa5..419aa3f9967b 100644 > --- a/fs/overlayfs/file.c > +++ b/fs/overlayfs/file.c > @@ -233,10 +233,30 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) > return ret; > } > > +static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) > +{ > + struct fd real; > + const struct cred *old_cred; > + int ret; > + Don't sync non-upper. same as ovl_dir_fsync() Thanks, Amir.
On Tue, May 8, 2018 at 7:14 AM, Amir Goldstein <amir73il@gmail.com> wrote: > On Mon, May 7, 2018 at 11:37 AM, Miklos Szeredi <mszeredi@redhat.com> wrote: >> Implement stacked fsync(). >> >> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> >> --- >> fs/overlayfs/file.c | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c >> index a7af56861aa5..419aa3f9967b 100644 >> --- a/fs/overlayfs/file.c >> +++ b/fs/overlayfs/file.c >> @@ -233,10 +233,30 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) >> return ret; >> } >> >> +static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) >> +{ >> + struct fd real; >> + const struct cred *old_cred; >> + int ret; >> + > > Don't sync non-upper. same as ovl_dir_fsync() Ah, that was about EROFS returned by lower fsync, right? Thanks, Miklos
On Tue, May 8, 2018 at 5:57 PM, Miklos Szeredi <miklos@szeredi.hu> wrote: > On Tue, May 8, 2018 at 7:14 AM, Amir Goldstein <amir73il@gmail.com> wrote: >> On Mon, May 7, 2018 at 11:37 AM, Miklos Szeredi <mszeredi@redhat.com> wrote: >>> Implement stacked fsync(). >>> >>> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> >>> --- >>> fs/overlayfs/file.c | 20 ++++++++++++++++++++ >>> 1 file changed, 20 insertions(+) >>> >>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c >>> index a7af56861aa5..419aa3f9967b 100644 >>> --- a/fs/overlayfs/file.c >>> +++ b/fs/overlayfs/file.c >>> @@ -233,10 +233,30 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) >>> return ret; >>> } >>> >>> +static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) >>> +{ >>> + struct fd real; >>> + const struct cred *old_cred; >>> + int ret; >>> + >> >> Don't sync non-upper. same as ovl_dir_fsync() > > Ah, that was about EROFS returned by lower fsync, right? > Yap. to reason to try and sync a lower file. Thanks, Amir.
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index a7af56861aa5..419aa3f9967b 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -233,10 +233,30 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) return ret; } +static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) +{ + struct fd real; + const struct cred *old_cred; + int ret; + + ret = ovl_real_fdget(file, &real); + if (ret) + return ret; + + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = vfs_fsync_range(real.file, start, end, datasync); + revert_creds(old_cred); + + fdput(real); + + return ret; +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, .llseek = ovl_llseek, .read_iter = ovl_read_iter, .write_iter = ovl_write_iter, + .fsync = ovl_fsync, };
Implement stacked fsync(). Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> --- fs/overlayfs/file.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)