All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: Don't get layout from mds for regular file which has been written.
@ 2013-07-11  8:59 majianpeng
  2013-07-12 21:06 ` Sage Weil
  0 siblings, 1 reply; 2+ messages in thread
From: majianpeng @ 2013-07-11  8:59 UTC (permalink / raw)
  To: sage; +Cc: ceph-devel

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@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ceph: Don't get layout from mds for regular file which has been written.
  2013-07-11  8:59 [PATCH] ceph: Don't get layout from mds for regular file which has been written majianpeng
@ 2013-07-12 21:06 ` Sage Weil
  0 siblings, 0 replies; 2+ messages in thread
From: Sage Weil @ 2013-07-12 21:06 UTC (permalink / raw)
  To: majianpeng; +Cc: ceph-devel

On Thu, 11 Jul 2013, majianpeng wrote:
> 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@gmail.com>
> ---
>  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*/

style nit: space after /* and before */

> +	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);

I think a more defensive approach would be to use the helper to see if we 
are holding any of the Fcrwbl caps; if so, we can assume the layout is 
valid.

Note that we should be doing the same thing in getxattr when exposing the 
ceph.file.layout[.*] xattrs.. right now they are blindingly assuming that 
whatever is in cache is correct, which isn't strictly true.  :/

sage


> -	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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-12 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-11  8:59 [PATCH] ceph: Don't get layout from mds for regular file which has been written majianpeng
2013-07-12 21:06 ` Sage Weil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.