Message ID | 1460044324-5298-10-git-send-email-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello Christoph, On 8 April 2016 at 01:52, Christoph Hellwig <hch@lst.de> wrote: > This is the per-I/O equivalent of O_DSYNC and O_SYNC, and very useful for > all kinds of file servers and storage targets. I've added some documentation for these flags to the man page, but in the process I realized that have a question. Do these flags provide equivalents of O_DSYNC and O_SYNC for the I/O operation, or for the file? What I mean is this: with, say, RWF_DSYNC, is it just the data written by this pwritev2() call that is synced to the underlying file, or is all dirty data for the file synced at that point? Thanks, Michael > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > fs/read_write.c | 6 +++++- > include/uapi/linux/fs.h | 2 ++ > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/fs/read_write.c b/fs/read_write.c > index cf377cf..3729d8d 100644 > --- a/fs/read_write.c > +++ b/fs/read_write.c > @@ -698,12 +698,16 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, > struct kiocb kiocb; > ssize_t ret; > > - if (flags & ~RWF_HIPRI) > + if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC)) > return -EOPNOTSUPP; > > init_sync_kiocb(&kiocb, filp); > if (flags & RWF_HIPRI) > kiocb.ki_flags |= IOCB_HIPRI; > + if (flags & RWF_DSYNC) > + kiocb.ki_flags |= IOCB_DSYNC; > + if (flags & RWF_SYNC) > + kiocb.ki_flags |= (IOCB_DSYNC | IOCB_SYNC); > kiocb.ki_pos = *ppos; > > ret = fn(&kiocb, iter); > diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h > index a079d50..e21fe04 100644 > --- a/include/uapi/linux/fs.h > +++ b/include/uapi/linux/fs.h > @@ -324,5 +324,7 @@ struct fscrypt_policy { > > /* flags for preadv2/pwritev2: */ > #define RWF_HIPRI 0x00000001 /* high priority request, poll if possible */ > +#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */ > +#define RWF_SYNC 0x00000004 /* per-IO O_SYNC */ > > #endif /* _UAPI_LINUX_FS_H */ > -- > 2.1.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-api" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Michael, On Sun, Aug 07, 2016 at 07:45:03AM +1000, Michael Kerrisk (man-pages) wrote: > I've added some documentation for these flags to the man page, but in > the process I realized that have a question. Do these flags provide > equivalents of O_DSYNC and O_SYNC for the I/O operation, or for the > file? What I mean is this: with, say, RWF_DSYNC, is it just the data > written by this pwritev2() call that is synced to the underlying file, > or is all dirty data for the file synced at that point? You beat me to it - I'm overdue sending you updates for these flags. The flags only affect the actual pwritev2 operation they are applied to. That is only the range just written is guaranteed to be on stable storage. Btw, I was going to just send you a patch, but it seems your update isn't out in the git tree yet, is it? -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Christoph, Sorry -- somehow I missed that you replied to my message... On 08/09/2016 08:15 PM, Christoph Hellwig wrote: > Hi Michael, > > On Sun, Aug 07, 2016 at 07:45:03AM +1000, Michael Kerrisk (man-pages) wrote: >> I've added some documentation for these flags to the man page, but in >> the process I realized that have a question. Do these flags provide >> equivalents of O_DSYNC and O_SYNC for the I/O operation, or for the >> file? What I mean is this: with, say, RWF_DSYNC, is it just the data >> written by this pwritev2() call that is synced to the underlying file, >> or is all dirty data for the file synced at that point? > > You beat me to it - I'm overdue sending you updates for these flags. > > The flags only affect the actual pwritev2 operation they are applied > to. That is only the range just written is guaranteed to be on > stable storage. Thanks. I added some words to make that clear: RWF_DSYNC (since Linux 4.7) Provide a per-write equivalent of the O_DSYNC open(2) flag. # This flag is meaningful only for pwritev2(), and its effect # applies only to the data range written by the system call. RWF_SYNC (since Linux 4.7) Provide a per-write equivalent of the O_SYNC open(2) flag. # This flag is meaningful only for pwritev2(), and its effect # applies only to the data range written by the system call. > Btw, I was going to just send you a patch, but it seems your update > isn't out in the git tree yet, is it? They were sitting in a private branch while I waited for (and missed) your reply. The changes are now pushed in master. Thanks for your help. Cheers, Michael
diff --git a/fs/read_write.c b/fs/read_write.c index cf377cf..3729d8d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -698,12 +698,16 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, struct kiocb kiocb; ssize_t ret; - if (flags & ~RWF_HIPRI) + if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC)) return -EOPNOTSUPP; init_sync_kiocb(&kiocb, filp); if (flags & RWF_HIPRI) kiocb.ki_flags |= IOCB_HIPRI; + if (flags & RWF_DSYNC) + kiocb.ki_flags |= IOCB_DSYNC; + if (flags & RWF_SYNC) + kiocb.ki_flags |= (IOCB_DSYNC | IOCB_SYNC); kiocb.ki_pos = *ppos; ret = fn(&kiocb, iter); diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index a079d50..e21fe04 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -324,5 +324,7 @@ struct fscrypt_policy { /* flags for preadv2/pwritev2: */ #define RWF_HIPRI 0x00000001 /* high priority request, poll if possible */ +#define RWF_DSYNC 0x00000002 /* per-IO O_DSYNC */ +#define RWF_SYNC 0x00000004 /* per-IO O_SYNC */ #endif /* _UAPI_LINUX_FS_H */
This is the per-I/O equivalent of O_DSYNC and O_SYNC, and very useful for all kinds of file servers and storage targets. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/read_write.c | 6 +++++- include/uapi/linux/fs.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-)