diff options
author | David Howells <dhowells@redhat.com> | 2018-04-06 15:17:25 +0200 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2018-04-09 22:54:48 +0200 |
commit | f3ddee8dc4e2cff37936afbeed2fdaa95b7fb7c6 (patch) | |
tree | e077005245794c5cacfc36eb6100cb3c819a8954 /fs/afs/fsclient.c | |
parent | afs: Split the dynroot stuff out and give it its own ops tables (diff) | |
download | linux-f3ddee8dc4e2cff37936afbeed2fdaa95b7fb7c6.tar.xz linux-f3ddee8dc4e2cff37936afbeed2fdaa95b7fb7c6.zip |
afs: Fix directory handling
AFS directories are structured blobs that are downloaded just like files
and then parsed by the lookup and readdir code and, as such, are currently
handled in the pagecache like any other file, with the entire directory
content being thrown away each time the directory changes.
However, since the blob is a known structure and since the data version
counter on a directory increases by exactly one for each change committed
to that directory, we can actually edit the directory locally rather than
fetching it from the server after each locally-induced change.
What we can't do, though, is mix data from the server and data from the
client since the server is technically at liberty to rearrange or compress
a directory if it sees fit, provided it updates the data version number
when it does so and breaks the callback (ie. sends a notification).
Further, lookup with lookup-ahead, readdir and, when it arrives, local
editing are likely want to scan the whole of a directory.
So directory handling needs to be improved to maintain the coherency of the
directory blob prior to permitting local directory editing.
To this end:
(1) If any directory page gets discarded, invalidate and reread the entire
directory.
(2) If readpage notes that if when it fetches a single page that the
version number has changed, the entire directory is flagged for
invalidation.
(3) Read as much of the directory in one go as we can.
Note that this removes local caching of directories in fscache for the
moment as we can't pass the pages to fscache_read_or_alloc_pages() since
page->lru is in use by the LRU.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/fsclient.c')
-rw-r--r-- | fs/afs/fsclient.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c index f7570d229dcc..b66ff0dc8a5a 100644 --- a/fs/afs/fsclient.c +++ b/fs/afs/fsclient.c @@ -101,8 +101,12 @@ void afs_update_inode_from_status(struct afs_vnode *vnode, vnode->fid.vid, vnode->fid.vnode, (unsigned long long) *expected_version); vnode->invalid_before = status->data_version; - set_bit(AFS_VNODE_DIR_MODIFIED, &vnode->flags); - set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags); + if (vnode->status.type == AFS_FTYPE_DIR) { + if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) + afs_stat_v(vnode, n_inval); + } else { + set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags); + } } } @@ -119,7 +123,7 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp, struct afs_file_status *status, struct afs_vnode *vnode, const afs_dataversion_t *expected_version, - afs_dataversion_t *_version) + struct afs_read *read_req) { const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp; u64 data_version, size; @@ -197,8 +201,11 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp, status->data_version = data_version; flags |= AFS_VNODE_DATA_CHANGED; } - if (_version) - *_version = data_version; + + if (read_req) { + read_req->data_version = data_version; + read_req->file_size = size; + } *_bp = (const void *)*_bp + sizeof(*xdr); @@ -543,8 +550,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call) bp = call->buffer; if (xdr_decode_AFSFetchStatus(&bp, &vnode->status, vnode, - &vnode->status.data_version, - &req->new_version) < 0) + &vnode->status.data_version, req) < 0) return -EBADMSG; xdr_decode_AFSCallBack(call, vnode, &bp); if (call->reply[1]) @@ -628,7 +634,7 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req) bp[6] = 0; bp[7] = htonl(lower_32_bits(req->len)); - atomic_inc(&req->usage); + refcount_inc(&req->usage); call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); @@ -671,7 +677,7 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req) bp[4] = htonl(lower_32_bits(req->pos)); bp[5] = htonl(lower_32_bits(req->len)); - atomic_inc(&req->usage); + refcount_inc(&req->usage); call->cb_break = fc->cb_break; afs_use_fs_server(call, fc->cbi); trace_afs_make_fs_call(call, &vnode->fid); |