Skip to content

Commit 4918b6d

Browse files
committed
ceph: add F_SYNC file flag to force sync (non-O_DIRECT) io
This allows us to force IO through the sync path which you normally only get when multiple clients are reading/writing to the same file or by mounting with -o sync. Among other things, this lets test programs verify correctness with a single mount. Reviewed-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Sage Weil <sage@newdream.net>
1 parent 252c672 commit 4918b6d

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎fs/ceph/file.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
643643

644644
if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 ||
645645
(iocb->ki_filp->f_flags & O_DIRECT) ||
646-
(inode->i_sb->s_flags & MS_SYNCHRONOUS))
646+
(inode->i_sb->s_flags & MS_SYNCHRONOUS) ||
647+
(fi->flags & CEPH_F_SYNC))
647648
/* hmm, this isn't really async... */
648649
ret = ceph_sync_read(filp, base, len, ppos, &checkeof);
649650
else
@@ -720,7 +721,8 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
720721

721722
if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 ||
722723
(iocb->ki_filp->f_flags & O_DIRECT) ||
723-
(inode->i_sb->s_flags & MS_SYNCHRONOUS)) {
724+
(inode->i_sb->s_flags & MS_SYNCHRONOUS) ||
725+
(fi->flags & CEPH_F_SYNC)) {
724726
ret = ceph_sync_write(file, iov->iov_base, iov->iov_len,
725727
&iocb->ki_pos);
726728
} else {

‎fs/ceph/ioctl.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ static long ceph_ioctl_lazyio(struct file *file)
231231
return 0;
232232
}
233233

234+
static long ceph_ioctl_syncio(struct file *file)
235+
{
236+
struct ceph_file_info *fi = file->private_data;
237+
238+
fi->flags |= CEPH_F_SYNC;
239+
return 0;
240+
}
241+
234242
long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
235243
{
236244
dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
@@ -249,6 +257,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
249257

250258
case CEPH_IOC_LAZYIO:
251259
return ceph_ioctl_lazyio(file);
260+
261+
case CEPH_IOC_SYNCIO:
262+
return ceph_ioctl_syncio(file);
252263
}
253264

254265
return -ENOTTY;

‎fs/ceph/ioctl.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ struct ceph_ioctl_dataloc {
4040
struct ceph_ioctl_dataloc)
4141

4242
#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)
43+
#define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
4344

4445
#endif

‎fs/ceph/super.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ extern void ceph_reservation_status(struct ceph_fs_client *client,
543543
/*
544544
* we keep buffered readdir results attached to file->private_data
545545
*/
546+
#define CEPH_F_SYNC 1
547+
546548
struct ceph_file_info {
547549
short fmode; /* initialized on open */
548550
short flags; /* CEPH_F_* */

0 commit comments

Comments
 (0)