diff options
author | Martin Brandenburg <martin@omnibond.com> | 2016-03-23 17:06:25 -0400 |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2016-03-23 17:36:16 -0400 |
commit | fecd86aac5a7621635b61e7491f0ed73610d76fa (patch) | |
tree | f8268df67637c7eee0d2d84b531006849880b4ef | |
parent | e8da254c415475d3df67966a198523bfe3ac0576 (diff) |
ornagefs: ensure that truncate has an up to date inode size
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
-rw-r--r-- | fs/orangefs/inode.c | 13 |
1 files changed, 12 insertions, 1 deletions
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) | |||
157 | { | 157 | { |
158 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); | 158 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
159 | struct orangefs_kernel_op_s *new_op; | 159 | struct orangefs_kernel_op_s *new_op; |
160 | loff_t orig_size = i_size_read(inode); | 160 | loff_t orig_size; |
161 | int ret = -EINVAL; | 161 | int ret = -EINVAL; |
162 | 162 | ||
163 | gossip_debug(GOSSIP_INODE_DEBUG, | 163 | gossip_debug(GOSSIP_INODE_DEBUG, |
@@ -168,6 +168,17 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) | |||
168 | orangefs_inode->refn.fs_id, | 168 | orangefs_inode->refn.fs_id, |
169 | iattr->ia_size); | 169 | iattr->ia_size); |
170 | 170 | ||
171 | /* Ensure that we have a up to date size, so we know if it changed. */ | ||
172 | ret = orangefs_inode_getattr(inode, 0, 1); | ||
173 | if (ret == -ESTALE) | ||
174 | ret = -EIO; | ||
175 | if (ret) { | ||
176 | gossip_err("%s: orangefs_inode_getattr failed, ret:%d:.\n", | ||
177 | __func__, ret); | ||
178 | return ret; | ||
179 | } | ||
180 | orig_size = i_size_read(inode); | ||
181 | |||
171 | truncate_setsize(inode, iattr->ia_size); | 182 | truncate_setsize(inode, iattr->ia_size); |
172 | 183 | ||
173 | new_op = op_alloc(ORANGEFS_VFS_OP_TRUNCATE); | 184 | new_op = op_alloc(ORANGEFS_VFS_OP_TRUNCATE); |