hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/nfs/unlink.c
....@@ -13,7 +13,7 @@
1313 #include <linux/sunrpc/clnt.h>
1414 #include <linux/nfs_fs.h>
1515 #include <linux/sched.h>
16
-#include <linux/swait.h>
16
+#include <linux/wait.h>
1717 #include <linux/namei.h>
1818 #include <linux/fsnotify.h>
1919
....@@ -31,7 +31,7 @@
3131 static void
3232 nfs_free_unlinkdata(struct nfs_unlinkdata *data)
3333 {
34
- put_rpccred(data->cred);
34
+ put_cred(data->cred);
3535 kfree(data->args.name.name);
3636 kfree(data);
3737 }
....@@ -39,6 +39,7 @@
3939 /**
4040 * nfs_async_unlink_done - Sillydelete post-processing
4141 * @task: rpc_task of the sillydelete
42
+ * @calldata: pointer to nfs_unlinkdata
4243 *
4344 * Do the directory attribute update.
4445 */
....@@ -52,32 +53,9 @@
5253 rpc_restart_call_prepare(task);
5354 }
5455
55
-#ifdef CONFIG_PREEMPT_RT_BASE
56
-static void nfs_down_anon(struct semaphore *sema)
57
-{
58
- down(sema);
59
-}
60
-
61
-static void nfs_up_anon(struct semaphore *sema)
62
-{
63
- up(sema);
64
-}
65
-
66
-#else
67
-static void nfs_down_anon(struct rw_semaphore *rwsem)
68
-{
69
- down_read_non_owner(rwsem);
70
-}
71
-
72
-static void nfs_up_anon(struct rw_semaphore *rwsem)
73
-{
74
- up_read_non_owner(rwsem);
75
-}
76
-#endif
77
-
7856 /**
7957 * nfs_async_unlink_release - Release the sillydelete data.
80
- * @task: rpc_task of the sillydelete
58
+ * @calldata: struct nfs_unlinkdata to release
8159 *
8260 * We need to call nfs_put_unlinkdata as a 'tk_release' task since the
8361 * rpc_task would be freed too.
....@@ -88,7 +66,7 @@
8866 struct dentry *dentry = data->dentry;
8967 struct super_block *sb = dentry->d_sb;
9068
91
- nfs_up_anon(&NFS_I(d_inode(dentry->d_parent))->rmdir_sem);
69
+ up_read_non_owner(&NFS_I(d_inode(dentry->d_parent))->rmdir_sem);
9270 d_lookup_done(dentry);
9371 nfs_free_unlinkdata(data);
9472 dput(dentry);
....@@ -120,7 +98,7 @@
12098 .callback_ops = &nfs_unlink_ops,
12199 .callback_data = data,
122100 .workqueue = nfsiod_workqueue,
123
- .flags = RPC_TASK_ASYNC,
101
+ .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF,
124102 };
125103 struct rpc_task *task;
126104 struct inode *dir = d_inode(data->dentry->d_parent);
....@@ -141,10 +119,10 @@
141119 struct inode *dir = d_inode(dentry->d_parent);
142120 struct dentry *alias;
143121
144
- nfs_down_anon(&NFS_I(dir)->rmdir_sem);
122
+ down_read_non_owner(&NFS_I(dir)->rmdir_sem);
145123 alias = d_alloc_parallel(dentry->d_parent, &data->args.name, &data->wq);
146124 if (IS_ERR(alias)) {
147
- nfs_up_anon(&NFS_I(dir)->rmdir_sem);
125
+ up_read_non_owner(&NFS_I(dir)->rmdir_sem);
148126 return 0;
149127 }
150128 if (!d_in_lookup(alias)) {
....@@ -166,7 +144,7 @@
166144 ret = 0;
167145 spin_unlock(&alias->d_lock);
168146 dput(alias);
169
- nfs_up_anon(&NFS_I(dir)->rmdir_sem);
147
+ up_read_non_owner(&NFS_I(dir)->rmdir_sem);
170148 /*
171149 * If we'd displaced old cached devname, free it. At that
172150 * point dentry is definitely not a root, so we won't need
....@@ -182,8 +160,8 @@
182160
183161 /**
184162 * nfs_async_unlink - asynchronous unlinking of a file
185
- * @dir: parent directory of dentry
186
- * @dentry: dentry to unlink
163
+ * @dentry: parent directory of dentry
164
+ * @name: name of dentry to unlink
187165 */
188166 static int
189167 nfs_async_unlink(struct dentry *dentry, const struct qstr *name)
....@@ -200,13 +178,9 @@
200178 goto out_free;
201179 data->args.name.len = name->len;
202180
203
- data->cred = rpc_lookup_cred();
204
- if (IS_ERR(data->cred)) {
205
- status = PTR_ERR(data->cred);
206
- goto out_free_name;
207
- }
181
+ data->cred = get_current_cred();
208182 data->res.dir_attr = &data->dir_attr;
209
- init_swait_queue_head(&data->wq);
183
+ init_waitqueue_head(&data->wq);
210184
211185 status = -EBUSY;
212186 spin_lock(&dentry->d_lock);
....@@ -225,8 +199,7 @@
225199 return 0;
226200 out_unlock:
227201 spin_unlock(&dentry->d_lock);
228
- put_rpccred(data->cred);
229
-out_free_name:
202
+ put_cred(data->cred);
230203 kfree(data->args.name.name);
231204 out_free:
232205 kfree(data);
....@@ -330,7 +303,7 @@
330303 iput(data->old_dir);
331304 iput(data->new_dir);
332305 nfs_sb_deactive(sb);
333
- put_rpccred(data->cred);
306
+ put_cred(data->cred);
334307 kfree(data);
335308 }
336309
....@@ -352,6 +325,7 @@
352325 * @new_dir: target directory for the rename
353326 * @old_dentry: original dentry to be renamed
354327 * @new_dentry: dentry to which the old_dentry should be renamed
328
+ * @complete: Function to run on successful completion
355329 *
356330 * It's expected that valid references to the dentries and inodes are held
357331 */
....@@ -367,7 +341,7 @@
367341 .callback_ops = &nfs_rename_ops,
368342 .workqueue = nfsiod_workqueue,
369343 .rpc_client = NFS_CLIENT(old_dir),
370
- .flags = RPC_TASK_ASYNC,
344
+ .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF,
371345 };
372346
373347 data = kzalloc(sizeof(*data), GFP_KERNEL);
....@@ -375,12 +349,7 @@
375349 return ERR_PTR(-ENOMEM);
376350 task_setup_data.callback_data = data;
377351
378
- data->cred = rpc_lookup_cred();
379
- if (IS_ERR(data->cred)) {
380
- struct rpc_task *task = ERR_CAST(data->cred);
381
- kfree(data);
382
- return task;
383
- }
352
+ data->cred = get_current_cred();
384353
385354 msg.rpc_argp = &data->args;
386355 msg.rpc_resp = &data->res;
....@@ -427,12 +396,6 @@
427396 nfs_cancel_async_unlink(dentry);
428397 return;
429398 }
430
-
431
- /*
432
- * vfs_unlink and the like do not issue this when a file is
433
- * sillyrenamed, so do it here.
434
- */
435
- fsnotify_nameremove(dentry, 0);
436399 }
437400
438401 #define SILLYNAME_PREFIX ".nfs"