Skip to content

Commit

Permalink
Merge tag 'afs-fixes-20171124' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/dhowells/linux-fs

Pull AFS fixes from David Howells:

 - Make AFS file locking work again.

 - Don't write to a page that's being written out, but wait for it to
   complete.

 - Do d_drop() and d_add() in the right places.

 - Put keys on error paths.

 - Remove some redundant code.

* tag 'afs-fixes-20171124' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  afs: remove redundant assignment of dvnode to itself
  afs: cell: Remove unnecessary code in afs_lookup_cell
  afs: Fix signal handling in some file ops
  afs: Fix some dentry handling in dir ops and missing key_puts
  afs: Make afs_write_begin() avoid writing to a page that's being stored
  afs: Fix file locking
  • Loading branch information
torvalds committed Nov 25, 2017
2 parents 7753ea0 + 43dd388 commit f61ec2c
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 279 deletions.
7 changes: 1 addition & 6 deletions fs/afs/cell.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,8 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,
rcu_read_lock();
cell = afs_lookup_cell_rcu(net, name, namesz);
rcu_read_unlock();
if (!IS_ERR(cell)) {
if (excl) {
afs_put_cell(net, cell);
return ERR_PTR(-EEXIST);
}
if (!IS_ERR(cell))
goto wait_for_cell;
}
}

/* Assume we're probably going to create a cell and preallocate and
Expand Down
25 changes: 14 additions & 11 deletions fs/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
if (fc->ac.error < 0)
return;

d_drop(new_dentry);

inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key,
newfid, newstatus, newcb, fc->cbi);
if (IS_ERR(inode)) {
Expand All @@ -775,9 +777,7 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
return;
}

d_instantiate(new_dentry, inode);
if (d_unhashed(new_dentry))
d_rehash(new_dentry);
d_add(new_dentry, inode);
}

/*
Expand Down Expand Up @@ -818,6 +818,8 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
ret = afs_end_vnode_operation(&fc);
if (ret < 0)
goto error_key;
} else {
goto error_key;
}

key_put(key);
Expand Down Expand Up @@ -972,7 +974,7 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
struct afs_fs_cursor fc;
struct afs_file_status newstatus;
struct afs_callback newcb;
struct afs_vnode *dvnode = dvnode = AFS_FS_I(dir);
struct afs_vnode *dvnode = AFS_FS_I(dir);
struct afs_fid newfid;
struct key *key;
int ret;
Expand Down Expand Up @@ -1006,6 +1008,8 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
ret = afs_end_vnode_operation(&fc);
if (ret < 0)
goto error_key;
} else {
goto error_key;
}

key_put(key);
Expand Down Expand Up @@ -1053,7 +1057,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
if (afs_begin_vnode_operation(&fc, dvnode, key)) {
if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) {
afs_end_vnode_operation(&fc);
return -ERESTARTSYS;
goto error_key;
}

while (afs_select_fileserver(&fc)) {
Expand All @@ -1071,6 +1075,8 @@ static int afs_link(struct dentry *from, struct inode *dir,
ret = afs_end_vnode_operation(&fc);
if (ret < 0)
goto error_key;
} else {
goto error_key;
}

key_put(key);
Expand Down Expand Up @@ -1130,6 +1136,8 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
ret = afs_end_vnode_operation(&fc);
if (ret < 0)
goto error_key;
} else {
goto error_key;
}

key_put(key);
Expand Down Expand Up @@ -1180,7 +1188,7 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (orig_dvnode != new_dvnode) {
if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) {
afs_end_vnode_operation(&fc);
return -ERESTARTSYS;
goto error_key;
}
}
while (afs_select_fileserver(&fc)) {
Expand All @@ -1199,14 +1207,9 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto error_key;
}

key_put(key);
_leave(" = 0");
return 0;

error_key:
key_put(key);
error:
d_drop(new_dentry);
_leave(" = %d", ret);
return ret;
}
Loading

0 comments on commit f61ec2c

Please sign in to comment.