Skip to content

Commit

Permalink
ornagefs: ensure that truncate has an up to date inode size
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
  • Loading branch information
Martin Brandenburg authored and hubcapsc committed Mar 23, 2016
1 parent e8da254 commit fecd86a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion fs/orangefs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit fecd86a

Please sign in to comment.