From: Martin Brandenburg Date: Wed, 23 Mar 2016 21:06:25 +0000 (-0400) Subject: ornagefs: ensure that truncate has an up to date inode size X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fecd86aac5a7621635b61e7491f0ed73610d76fa;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ornagefs: ensure that truncate has an up to date inode size Signed-off-by: Martin Brandenburg Signed-off-by: Mike Marshall --- diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 2e521ec734c4..2382e267b49e 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -157,7 +157,7 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) { struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_kernel_op_s *new_op; - loff_t orig_size = i_size_read(inode); + loff_t orig_size; int ret = -EINVAL; gossip_debug(GOSSIP_INODE_DEBUG, @@ -168,6 +168,17 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) orangefs_inode->refn.fs_id, iattr->ia_size); + /* Ensure that we have a up to date size, so we know if it changed. */ + ret = orangefs_inode_getattr(inode, 0, 1); + if (ret == -ESTALE) + ret = -EIO; + if (ret) { + gossip_err("%s: orangefs_inode_getattr failed, ret:%d:.\n", + __func__, ret); + return ret; + } + orig_size = i_size_read(inode); + truncate_setsize(inode, iattr->ia_size); new_op = op_alloc(ORANGEFS_VFS_OP_TRUNCATE);