diff options
author | Sage Weil <sage@newdream.net> | 2010-05-26 17:31:27 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-08-01 23:11:39 -0400 |
commit | 33caad324b88f75f42d836735d86feaafb3b40cf (patch) | |
tree | 57e50ce5bdc181ea296191784c4d57999c51207e /fs/ceph | |
parent | 8c6e9229fc1989cf263a6fcd4ff406d7f473f966 (diff) |
ceph: perform lazy writes when file mode and caps permit
If we have marked a file as "lazy" (using the ceph ioctl), perform buffered
writes when the MDS caps allow it.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/caps.c | 7 | ||||
-rw-r--r-- | fs/ceph/file.c | 12 |
2 files changed, 11 insertions, 8 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index b81be9a56487..1a70a3ebf013 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -337,8 +337,7 @@ static struct ceph_cap *__get_cap_for_mds(struct ceph_inode_info *ci, int mds) | |||
337 | } | 337 | } |
338 | 338 | ||
339 | /* | 339 | /* |
340 | * Return id of any MDS with a cap, preferably FILE_WR|WRBUFFER|EXCL, else | 340 | * Return id of any MDS with a cap, preferably FILE_WR|BUFFER|EXCL, else -1. |
341 | * -1. | ||
342 | */ | 341 | */ |
343 | static int __ceph_get_cap_mds(struct ceph_inode_info *ci, u32 *mseq) | 342 | static int __ceph_get_cap_mds(struct ceph_inode_info *ci, u32 *mseq) |
344 | { | 343 | { |
@@ -346,7 +345,7 @@ static int __ceph_get_cap_mds(struct ceph_inode_info *ci, u32 *mseq) | |||
346 | int mds = -1; | 345 | int mds = -1; |
347 | struct rb_node *p; | 346 | struct rb_node *p; |
348 | 347 | ||
349 | /* prefer mds with WR|WRBUFFER|EXCL caps */ | 348 | /* prefer mds with WR|BUFFER|EXCL caps */ |
350 | for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { | 349 | for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { |
351 | cap = rb_entry(p, struct ceph_cap, ci_node); | 350 | cap = rb_entry(p, struct ceph_cap, ci_node); |
352 | mds = cap->mds; | 351 | mds = cap->mds; |
@@ -831,7 +830,7 @@ int __ceph_caps_file_wanted(struct ceph_inode_info *ci) | |||
831 | { | 830 | { |
832 | int want = 0; | 831 | int want = 0; |
833 | int mode; | 832 | int mode; |
834 | for (mode = 0; mode < 4; mode++) | 833 | for (mode = 0; mode < CEPH_FILE_MODE_NUM; mode++) |
835 | if (ci->i_nr_by_mode[mode]) | 834 | if (ci->i_nr_by_mode[mode]) |
836 | want |= ceph_caps_for_mode(mode); | 835 | want |= ceph_caps_for_mode(mode); |
837 | return want; | 836 | return want; |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 7c08698fad3e..85c86ed5f4c0 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -807,11 +807,12 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
807 | unsigned long nr_segs, loff_t pos) | 807 | unsigned long nr_segs, loff_t pos) |
808 | { | 808 | { |
809 | struct file *file = iocb->ki_filp; | 809 | struct file *file = iocb->ki_filp; |
810 | struct ceph_file_info *fi = file->private_data; | ||
810 | struct inode *inode = file->f_dentry->d_inode; | 811 | struct inode *inode = file->f_dentry->d_inode; |
811 | struct ceph_inode_info *ci = ceph_inode(inode); | 812 | struct ceph_inode_info *ci = ceph_inode(inode); |
812 | struct ceph_osd_client *osdc = &ceph_sb_to_client(inode->i_sb)->osdc; | 813 | struct ceph_osd_client *osdc = &ceph_sb_to_client(inode->i_sb)->osdc; |
813 | loff_t endoff = pos + iov->iov_len; | 814 | loff_t endoff = pos + iov->iov_len; |
814 | int got = 0; | 815 | int want, got = 0; |
815 | int ret, err; | 816 | int ret, err; |
816 | 817 | ||
817 | if (ceph_snap(inode) != CEPH_NOSNAP) | 818 | if (ceph_snap(inode) != CEPH_NOSNAP) |
@@ -824,8 +825,11 @@ retry_snap: | |||
824 | dout("aio_write %p %llx.%llx %llu~%u getting caps. i_size %llu\n", | 825 | dout("aio_write %p %llx.%llx %llu~%u getting caps. i_size %llu\n", |
825 | inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len, | 826 | inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len, |
826 | inode->i_size); | 827 | inode->i_size); |
827 | ret = ceph_get_caps(ci, CEPH_CAP_FILE_WR, CEPH_CAP_FILE_BUFFER, | 828 | if (fi->fmode & CEPH_FILE_MODE_LAZY) |
828 | &got, endoff); | 829 | want = CEPH_CAP_FILE_BUFFER | CEPH_CAP_FILE_LAZYIO; |
830 | else | ||
831 | want = CEPH_CAP_FILE_BUFFER; | ||
832 | ret = ceph_get_caps(ci, CEPH_CAP_FILE_WR, want, &got, endoff); | ||
829 | if (ret < 0) | 833 | if (ret < 0) |
830 | goto out; | 834 | goto out; |
831 | 835 | ||
@@ -833,7 +837,7 @@ retry_snap: | |||
833 | inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len, | 837 | inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len, |
834 | ceph_cap_string(got)); | 838 | ceph_cap_string(got)); |
835 | 839 | ||
836 | if ((got & CEPH_CAP_FILE_BUFFER) == 0 || | 840 | if ((got & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_LAZYIO)) == 0 || |
837 | (iocb->ki_filp->f_flags & O_DIRECT) || | 841 | (iocb->ki_filp->f_flags & O_DIRECT) || |
838 | (inode->i_sb->s_flags & MS_SYNCHRONOUS)) { | 842 | (inode->i_sb->s_flags & MS_SYNCHRONOUS)) { |
839 | ret = ceph_sync_write(file, iov->iov_base, iov->iov_len, | 843 | ret = ceph_sync_write(file, iov->iov_base, iov->iov_len, |