Skip to content

Commit

Permalink
ceph: add F_SYNC file flag to force sync (non-O_DIRECT) io
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sage Weil committed Jul 26, 2011
1 parent 252c672 commit 4918b6d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,

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

if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 ||
(iocb->ki_filp->f_flags & O_DIRECT) ||
(inode->i_sb->s_flags & MS_SYNCHRONOUS)) {
(inode->i_sb->s_flags & MS_SYNCHRONOUS) ||
(fi->flags & CEPH_F_SYNC)) {
ret = ceph_sync_write(file, iov->iov_base, iov->iov_len,
&iocb->ki_pos);
} else {
Expand Down
11 changes: 11 additions & 0 deletions fs/ceph/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ static long ceph_ioctl_lazyio(struct file *file)
return 0;
}

static long ceph_ioctl_syncio(struct file *file)
{
struct ceph_file_info *fi = file->private_data;

fi->flags |= CEPH_F_SYNC;
return 0;
}

long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
Expand All @@ -249,6 +257,9 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

case CEPH_IOC_LAZYIO:
return ceph_ioctl_lazyio(file);

case CEPH_IOC_SYNCIO:
return ceph_ioctl_syncio(file);
}

return -ENOTTY;
Expand Down
1 change: 1 addition & 0 deletions fs/ceph/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ struct ceph_ioctl_dataloc {
struct ceph_ioctl_dataloc)

#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)
#define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)

#endif
2 changes: 2 additions & 0 deletions fs/ceph/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ extern void ceph_reservation_status(struct ceph_fs_client *client,
/*
* we keep buffered readdir results attached to file->private_data
*/
#define CEPH_F_SYNC 1

struct ceph_file_info {
short fmode; /* initialized on open */
short flags; /* CEPH_F_* */
Expand Down

0 comments on commit 4918b6d

Please sign in to comment.