Skip to content

Commit ab487a4

Browse files
committed
afs: Maintain netfs_i_context::remote_i_size
Make afs use netfslib's tracking for the server's idea of what the current inode size is independently of inode->i_size. We really want to use this value when calculating the new vnode size when initiating a StoreData RPC op rather than the size stat() presents to the user (ie. inode->i_size) as the latter is affected by as-yet uncommitted writes. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/164623014626.3564931.8375344024648265358.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/164678220204.1200972.17408022517463940584.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/164692923592.2099075.5466132542956550401.stgit@warthog.procyon.org.uk/ # v3
1 parent 4058f74 commit ab487a4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/afs/inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static void afs_apply_status(struct afs_operation *op,
246246
* idea of what the size should be that's not the same as
247247
* what's on the server.
248248
*/
249+
vnode->netfs_ctx.remote_i_size = status->size;
249250
if (change_size) {
250251
afs_set_i_size(vnode, status->size);
251252
inode->i_ctime = t;

fs/afs/write.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,10 @@ static const struct afs_operation_ops afs_store_data_operation = {
353353
static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_t pos,
354354
bool laundering)
355355
{
356+
struct netfs_i_context *ictx = &vnode->netfs_ctx;
356357
struct afs_operation *op;
357358
struct afs_wb_key *wbk = NULL;
358-
loff_t size = iov_iter_count(iter), i_size;
359+
loff_t size = iov_iter_count(iter);
359360
int ret = -ENOKEY;
360361

361362
_enter("%s{%llx:%llu.%u},%llx,%llx",
@@ -377,15 +378,13 @@ static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_t
377378
return -ENOMEM;
378379
}
379380

380-
i_size = i_size_read(&vnode->vfs_inode);
381-
382381
afs_op_set_vnode(op, 0, vnode);
383382
op->file[0].dv_delta = 1;
384383
op->file[0].modification = true;
385384
op->store.write_iter = iter;
386385
op->store.pos = pos;
387386
op->store.size = size;
388-
op->store.i_size = max(pos + size, i_size);
387+
op->store.i_size = max(pos + size, ictx->remote_i_size);
389388
op->store.laundering = laundering;
390389
op->mtime = vnode->vfs_inode.i_mtime;
391390
op->flags |= AFS_OPERATION_UNINTR;

0 commit comments

Comments
 (0)