Skip to content

Commit f61ec2c

Browse files
committed
Merge tag 'afs-fixes-20171124' of git://git.kernel.org/pub/scm/linux/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
2 parents 7753ea0 + 43dd388 commit f61ec2c

File tree

8 files changed

+405
-279
lines changed

8 files changed

+405
-279
lines changed

fs/afs/cell.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,8 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,
207207
rcu_read_lock();
208208
cell = afs_lookup_cell_rcu(net, name, namesz);
209209
rcu_read_unlock();
210-
if (!IS_ERR(cell)) {
211-
if (excl) {
212-
afs_put_cell(net, cell);
213-
return ERR_PTR(-EEXIST);
214-
}
210+
if (!IS_ERR(cell))
215211
goto wait_for_cell;
216-
}
217212
}
218213

219214
/* Assume we're probably going to create a cell and preallocate and

fs/afs/dir.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
765765
if (fc->ac.error < 0)
766766
return;
767767

768+
d_drop(new_dentry);
769+
768770
inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key,
769771
newfid, newstatus, newcb, fc->cbi);
770772
if (IS_ERR(inode)) {
@@ -775,9 +777,7 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
775777
return;
776778
}
777779

778-
d_instantiate(new_dentry, inode);
779-
if (d_unhashed(new_dentry))
780-
d_rehash(new_dentry);
780+
d_add(new_dentry, inode);
781781
}
782782

783783
/*
@@ -818,6 +818,8 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
818818
ret = afs_end_vnode_operation(&fc);
819819
if (ret < 0)
820820
goto error_key;
821+
} else {
822+
goto error_key;
821823
}
822824

823825
key_put(key);
@@ -972,7 +974,7 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
972974
struct afs_fs_cursor fc;
973975
struct afs_file_status newstatus;
974976
struct afs_callback newcb;
975-
struct afs_vnode *dvnode = dvnode = AFS_FS_I(dir);
977+
struct afs_vnode *dvnode = AFS_FS_I(dir);
976978
struct afs_fid newfid;
977979
struct key *key;
978980
int ret;
@@ -1006,6 +1008,8 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
10061008
ret = afs_end_vnode_operation(&fc);
10071009
if (ret < 0)
10081010
goto error_key;
1011+
} else {
1012+
goto error_key;
10091013
}
10101014

10111015
key_put(key);
@@ -1053,7 +1057,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
10531057
if (afs_begin_vnode_operation(&fc, dvnode, key)) {
10541058
if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) {
10551059
afs_end_vnode_operation(&fc);
1056-
return -ERESTARTSYS;
1060+
goto error_key;
10571061
}
10581062

10591063
while (afs_select_fileserver(&fc)) {
@@ -1071,6 +1075,8 @@ static int afs_link(struct dentry *from, struct inode *dir,
10711075
ret = afs_end_vnode_operation(&fc);
10721076
if (ret < 0)
10731077
goto error_key;
1078+
} else {
1079+
goto error_key;
10741080
}
10751081

10761082
key_put(key);
@@ -1130,6 +1136,8 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
11301136
ret = afs_end_vnode_operation(&fc);
11311137
if (ret < 0)
11321138
goto error_key;
1139+
} else {
1140+
goto error_key;
11331141
}
11341142

11351143
key_put(key);
@@ -1180,7 +1188,7 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
11801188
if (orig_dvnode != new_dvnode) {
11811189
if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) {
11821190
afs_end_vnode_operation(&fc);
1183-
return -ERESTARTSYS;
1191+
goto error_key;
11841192
}
11851193
}
11861194
while (afs_select_fileserver(&fc)) {
@@ -1199,14 +1207,9 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
11991207
goto error_key;
12001208
}
12011209

1202-
key_put(key);
1203-
_leave(" = 0");
1204-
return 0;
1205-
12061210
error_key:
12071211
key_put(key);
12081212
error:
1209-
d_drop(new_dentry);
12101213
_leave(" = %d", ret);
12111214
return ret;
12121215
}

0 commit comments

Comments
 (0)