[PATCH] ceph: Don't get layout from mds for regular file which has been written.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For regular file which has been written, it can't change layout.
So it can get layout from local rather than mds.

Signed-off-by: Jianpeng Ma <majianpeng@xxxxxxxxx>
---
 fs/ceph/ioctl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index e0b4ef3..2b74879 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -17,10 +17,16 @@
 static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
 {
 	struct ceph_inode_info *ci = ceph_inode(file_inode(file));
+	struct inode *inode = file_inode(file);
 	struct ceph_ioctl_layout l;
-	int err;
+	int err = 0;
+
+	/*For regular file which has been written,it can't change layout
+	 * So it don't get layout from mds*/
+	if (!(S_ISREG(inode->i_mode) && (i_size_read(inode) > 0 ||
+		ci->i_truncate_seq > 1)))
+		err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT);
 
-	err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT);
 	if (!err) {
 		l.stripe_unit = ceph_file_layout_su(ci->i_layout);
 		l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
-- 
1.8.1.2
?韬{.n?????%??檩??w?{.n????u朕?Ф?塄}?财??j:+v??????2??璀??摺?囤??z夸z罐?+?????w棹f





[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux