Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+25 -19
+2 -2
fs/afs/callback.c
··· 275 275 struct afs_super_info *as = AFS_FS_S(cbi->sb); 276 276 struct afs_volume *volume = as->volume; 277 277 278 - write_lock(&volume->cb_break_lock); 278 + write_lock(&volume->cb_v_break_lock); 279 279 volume->cb_v_break++; 280 - write_unlock(&volume->cb_break_lock); 280 + write_unlock(&volume->cb_v_break_lock); 281 281 } else { 282 282 data.volume = NULL; 283 283 data.fid = *fid;
+19 -12
fs/afs/inode.c
··· 56 56 } 57 57 58 58 /* 59 + * Set the file size and block count. Estimate the number of 512 bytes blocks 60 + * used, rounded up to nearest 1K for consistency with other AFS clients. 61 + */ 62 + static void afs_set_i_size(struct afs_vnode *vnode, u64 size) 63 + { 64 + i_size_write(&vnode->vfs_inode, size); 65 + vnode->vfs_inode.i_blocks = ((size + 1023) >> 10) << 1; 66 + } 67 + 68 + /* 59 69 * Initialise an inode from the vnode status. 60 70 */ 61 71 static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key, ··· 134 124 return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type); 135 125 } 136 126 137 - /* 138 - * Estimate 512 bytes blocks used, rounded up to nearest 1K 139 - * for consistency with other AFS clients. 140 - */ 141 - inode->i_blocks = ((i_size_read(inode) + 1023) >> 10) << 1; 142 - i_size_write(&vnode->vfs_inode, status->size); 127 + afs_set_i_size(vnode, status->size); 143 128 144 129 vnode->invalid_before = status->data_version; 145 130 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version); ··· 212 207 213 208 if (expected_version && 214 209 *expected_version != status->data_version) { 215 - kdebug("vnode modified %llx on {%llx:%llu} [exp %llx] %s", 216 - (unsigned long long) status->data_version, 217 - vnode->fid.vid, vnode->fid.vnode, 218 - (unsigned long long) *expected_version, 219 - fc->type ? fc->type->name : "???"); 210 + if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) 211 + pr_warn("kAFS: vnode modified {%llx:%llu} %llx->%llx %s\n", 212 + vnode->fid.vid, vnode->fid.vnode, 213 + (unsigned long long)*expected_version, 214 + (unsigned long long)status->data_version, 215 + fc->type ? fc->type->name : "???"); 216 + 220 217 vnode->invalid_before = status->data_version; 221 218 if (vnode->status.type == AFS_FTYPE_DIR) { 222 219 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) ··· 237 230 238 231 if (data_changed) { 239 232 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version); 240 - i_size_write(&vnode->vfs_inode, status->size); 233 + afs_set_i_size(vnode, status->size); 241 234 } 242 235 } 243 236
+3 -5
fs/afs/internal.h
··· 109 109 struct rxrpc_call *rxcall; /* RxRPC call handle */ 110 110 struct key *key; /* security for this call */ 111 111 struct afs_net *net; /* The network namespace */ 112 - union { 113 - struct afs_server *server; 114 - struct afs_vlserver *vlserver; 115 - }; 112 + struct afs_server *server; /* The fileserver record if fs op (pins ref) */ 113 + struct afs_vlserver *vlserver; /* The vlserver record if vl op */ 116 114 struct afs_cb_interest *cbi; /* Callback interest for server used */ 117 115 struct afs_vnode *lvnode; /* vnode being locked */ 118 116 void *request; /* request data (first part) */ ··· 614 616 unsigned int servers_seq; /* Incremented each time ->servers changes */ 615 617 616 618 unsigned cb_v_break; /* Break-everything counter. */ 617 - rwlock_t cb_break_lock; 619 + rwlock_t cb_v_break_lock; 618 620 619 621 afs_voltype_t type; /* type of volume */ 620 622 short error;
+1
fs/afs/volume.c
··· 43 43 atomic_set(&volume->usage, 1); 44 44 INIT_LIST_HEAD(&volume->proc_link); 45 45 rwlock_init(&volume->servers_lock); 46 + rwlock_init(&volume->cb_v_break_lock); 46 47 memcpy(volume->name, vldb->name, vldb->name_len + 1); 47 48 48 49 slist = afs_alloc_server_list(params->cell, params->key, vldb, type_mask);