aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-07-26 14:26:07 -0400
committerSage Weil <sage@newdream.net>2011-07-26 14:26:07 -0400
commit4918b6d140c4822201ebbe2f070875332aff337b (patch)
tree0327a0a68acd2f8209893b4770ba3c9d9264041c
parent252c6728de604d6a897d85e212996811d5c8c46c (diff)
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>
-rw-r--r--fs/ceph/file.c6
-rw-r--r--fs/ceph/ioctl.c11
-rw-r--r--fs/ceph/ioctl.h1
-rw-r--r--fs/ceph/super.h2
4 files changed, 18 insertions, 2 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 4698a5c553dc..44e4fe9fba02 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -643,7 +643,8 @@ again:
643 643
644 if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 || 644 if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 ||
645 (iocb->ki_filp->f_flags & O_DIRECT) || 645 (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))
647 /* hmm, this isn't really async... */ 648 /* hmm, this isn't really async... */
648 ret = ceph_sync_read(filp, base, len, ppos, &checkeof); 649 ret = ceph_sync_read(filp, base, len, ppos, &checkeof);
649 else 650 else
@@ -720,7 +721,8 @@ retry_snap:
720 721
721 if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 || 722 if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 ||
722 (iocb->ki_filp->f_flags & O_DIRECT) || 723 (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)) {
724 ret = ceph_sync_write(file, iov->iov_base, iov->iov_len, 726 ret = ceph_sync_write(file, iov->iov_base, iov->iov_len,
725 &iocb->ki_pos); 727 &iocb->ki_pos);
726 } else { 728 } else {
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index ef0b5f48e13a..a757a5680578 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -231,6 +231,14 @@ static long ceph_ioctl_lazyio(struct file *file)
231 return 0; 231 return 0;
232} 232}
233 233
234static 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
234long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 242long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
235{ 243{
236 dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg); 244 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)
249 257
250 case CEPH_IOC_LAZYIO: 258 case CEPH_IOC_LAZYIO:
251 return ceph_ioctl_lazyio(file); 259 return ceph_ioctl_lazyio(file);
260
261 case CEPH_IOC_SYNCIO:
262 return ceph_ioctl_syncio(file);
252 } 263 }
253 264
254 return -ENOTTY; 265 return -ENOTTY;
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
index 52e8fd74d450..0c5167e43180 100644
--- a/fs/ceph/ioctl.h
+++ b/fs/ceph/ioctl.h
@@ -40,5 +40,6 @@ struct ceph_ioctl_dataloc {
40 struct ceph_ioctl_dataloc) 40 struct ceph_ioctl_dataloc)
41 41
42#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4) 42#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)
43#define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
43 44
44#endif 45#endif
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 8febe6fce2b1..cdb17d36755c 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -543,6 +543,8 @@ extern void ceph_reservation_status(struct ceph_fs_client *client,
543/* 543/*
544 * we keep buffered readdir results attached to file->private_data 544 * we keep buffered readdir results attached to file->private_data
545 */ 545 */
546#define CEPH_F_SYNC 1
547
546struct ceph_file_info { 548struct ceph_file_info {
547 short fmode; /* initialized on open */ 549 short fmode; /* initialized on open */
548 short flags; /* CEPH_F_* */ 550 short flags; /* CEPH_F_* */