mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
AFS fixes
-----BEGIN PGP SIGNATURE----- iQIVAwUAXRMn5vu3V2unywtrAQICpA/+IIINk6MJVQDzGhOnvWrbGdPnOdJEUyLN B9U4bLZJRg/j+Sqodn+fXIfsEO4FQflkSJD+xoBi4pzBZcr0xkLUVOog/1S7dv4J bPVT9p2f3ITNiatmisOrUe1InuHa6Wb/cUnQaLLRhd7NqbawKGRQG4tv4CGwKn67 dJIOOm/iTCs1ACES4C5QOpU7/DWK38Pn3BbnN21bFzDgfbtbdDTaFFkhFtXy78oB Gcj5g+ULpkKBcuJThFuJUPZ9E4qICNZR4kJXEULSvykDDRzluhJmQ+v8btm6NJsq hMqTrT9M2y114V1OqXj3me7tA6wOEAfTQ0WzpzF2SmyFQKnSly/EkWc4HZXFD/8O BczCcABUbuKNE/pJSELx6k1M0+00QfeLcjHPc6joZFCni3lMdYWOncn/syyHw5P+ rc9JQsy3+dLcFsaVQ5eGmX6NDc70dCrAlS6MllIzSBcwAVCctTKwm0meaSW6B2y6 VymPy+cqi1RxMKyiQ0hAeU7Xe6yqFcl6rtonfCQqRLxkfzrCXkDp6/ELOXBzDft1 ey6+N3WsmWW7YSPuM/SIZKV66rshlflj0w+FRluZEEAF1NYeYqXUDvK/S8KC9kPG AXUDvhI+tBpxg1AVz94JN714VmkbY23xV0g44eQsdqSQm2YvsxiFCSWZZ6L/KEWe kWQc6BGDCB0= =YTdG -----END PGP SIGNATURE----- Merge tag 'afs-fixes-20190620' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs Pull AFS fixes from David Howells: "The in-kernel AFS client has been undergoing testing on opendev.org on one of their mirror machines. They are using AFS to hold data that is then served via apache, and Ian Wienand had reported seeing oopses, spontaneous machine reboots and updates to volumes going missing. This patch series appears to have fixed the problem, very probably due to patch (2), but it's not 100% certain. (1) Fix the printing of the "vnode modified" warning to exclude checks on files for which we don't have a callback promise from the server (and so don't expect the server to tell us when it changes). Without this, for every file or directory for which we still have an in-core inode that gets changed on the server, we may get a message logged when we next look at it. This can happen in bulk if, for instance, someone does "vos release" to update a R/O volume from a R/W volume and a whole set of files are all changed together. We only really want to log a message if the file changed and the server didn't tell us about it or we failed to track the state internally. (2) Fix accidental corruption of either afs_vlserver struct objects or the the following memory locations (which could hold anything). The issue is caused by a union that points to two different structs in struct afs_call (to save space in the struct). The call cleanup code assumes that it can simply call the cleanup for one of those structs if not NULL - when it might be actually pointing to the other struct. This means that every Volume Location RPC op is going to corrupt something. (3) Fix an uninitialised spinlock. This isn't too bad, it just causes a one-off warning if lockdep is enabled when "vos release" is called, but the spinlock still behaves correctly. (4) Fix the setting of i_block in the inode. This causes du, for example, to produce incorrect results, but otherwise should not be dangerous to the kernel" * tag 'afs-fixes-20190620' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: afs: Fix setting of i_blocks afs: Fix uninitialised spinlock afs_volume::cb_break_lock afs: Fix vlserver record corruption afs: Fix over zealous "vnode modified" warnings
This commit is contained in:
commit
cd0f3aaebc
@ -275,9 +275,9 @@ static void afs_break_one_callback(struct afs_server *server,
|
||||
struct afs_super_info *as = AFS_FS_S(cbi->sb);
|
||||
struct afs_volume *volume = as->volume;
|
||||
|
||||
write_lock(&volume->cb_break_lock);
|
||||
write_lock(&volume->cb_v_break_lock);
|
||||
volume->cb_v_break++;
|
||||
write_unlock(&volume->cb_break_lock);
|
||||
write_unlock(&volume->cb_v_break_lock);
|
||||
} else {
|
||||
data.volume = NULL;
|
||||
data.fid = *fid;
|
||||
|
@ -55,6 +55,16 @@ static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *paren
|
||||
dump_stack();
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the file size and block count. Estimate the number of 512 bytes blocks
|
||||
* used, rounded up to nearest 1K for consistency with other AFS clients.
|
||||
*/
|
||||
static void afs_set_i_size(struct afs_vnode *vnode, u64 size)
|
||||
{
|
||||
i_size_write(&vnode->vfs_inode, size);
|
||||
vnode->vfs_inode.i_blocks = ((size + 1023) >> 10) << 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise an inode from the vnode status.
|
||||
*/
|
||||
@ -124,12 +134,7 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
|
||||
return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Estimate 512 bytes blocks used, rounded up to nearest 1K
|
||||
* for consistency with other AFS clients.
|
||||
*/
|
||||
inode->i_blocks = ((i_size_read(inode) + 1023) >> 10) << 1;
|
||||
i_size_write(&vnode->vfs_inode, status->size);
|
||||
afs_set_i_size(vnode, status->size);
|
||||
|
||||
vnode->invalid_before = status->data_version;
|
||||
inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
|
||||
@ -207,11 +212,13 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
|
||||
|
||||
if (expected_version &&
|
||||
*expected_version != status->data_version) {
|
||||
kdebug("vnode modified %llx on {%llx:%llu} [exp %llx] %s",
|
||||
(unsigned long long) status->data_version,
|
||||
vnode->fid.vid, vnode->fid.vnode,
|
||||
(unsigned long long) *expected_version,
|
||||
fc->type ? fc->type->name : "???");
|
||||
if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags))
|
||||
pr_warn("kAFS: vnode modified {%llx:%llu} %llx->%llx %s\n",
|
||||
vnode->fid.vid, vnode->fid.vnode,
|
||||
(unsigned long long)*expected_version,
|
||||
(unsigned long long)status->data_version,
|
||||
fc->type ? fc->type->name : "???");
|
||||
|
||||
vnode->invalid_before = status->data_version;
|
||||
if (vnode->status.type == AFS_FTYPE_DIR) {
|
||||
if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
|
||||
@ -230,7 +237,7 @@ static void afs_apply_status(struct afs_fs_cursor *fc,
|
||||
|
||||
if (data_changed) {
|
||||
inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
|
||||
i_size_write(&vnode->vfs_inode, status->size);
|
||||
afs_set_i_size(vnode, status->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,8 @@ struct afs_call {
|
||||
struct rxrpc_call *rxcall; /* RxRPC call handle */
|
||||
struct key *key; /* security for this call */
|
||||
struct afs_net *net; /* The network namespace */
|
||||
union {
|
||||
struct afs_server *server;
|
||||
struct afs_vlserver *vlserver;
|
||||
};
|
||||
struct afs_server *server; /* The fileserver record if fs op (pins ref) */
|
||||
struct afs_vlserver *vlserver; /* The vlserver record if vl op */
|
||||
struct afs_cb_interest *cbi; /* Callback interest for server used */
|
||||
struct afs_vnode *lvnode; /* vnode being locked */
|
||||
void *request; /* request data (first part) */
|
||||
@ -616,7 +614,7 @@ struct afs_volume {
|
||||
unsigned int servers_seq; /* Incremented each time ->servers changes */
|
||||
|
||||
unsigned cb_v_break; /* Break-everything counter. */
|
||||
rwlock_t cb_break_lock;
|
||||
rwlock_t cb_v_break_lock;
|
||||
|
||||
afs_voltype_t type; /* type of volume */
|
||||
short error;
|
||||
|
@ -43,6 +43,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,
|
||||
atomic_set(&volume->usage, 1);
|
||||
INIT_LIST_HEAD(&volume->proc_link);
|
||||
rwlock_init(&volume->servers_lock);
|
||||
rwlock_init(&volume->cb_v_break_lock);
|
||||
memcpy(volume->name, vldb->name, vldb->name_len + 1);
|
||||
|
||||
slist = afs_alloc_server_list(params->cell, params->key, vldb, type_mask);
|
||||
|
Loading…
Reference in New Issue
Block a user