]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - fs/aufs/vfsub.c
UBUNTU: SAUCE: Import aufs driver
[mirror_ubuntu-zesty-kernel.git] / fs / aufs / vfsub.c
1 /*
2 * Copyright (C) 2005-2016 Junjiro R. Okajima
3 *
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 * sub-routines for VFS
20 */
21
22 #include <linux/namei.h>
23 #include <linux/nsproxy.h>
24 #include <linux/security.h>
25 #include <linux/splice.h>
26 #include "../fs/mount.h"
27 #include "aufs.h"
28
29 #ifdef CONFIG_AUFS_BR_FUSE
30 int vfsub_test_mntns(struct vfsmount *mnt, struct super_block *h_sb)
31 {
32 struct nsproxy *ns;
33
34 if (!au_test_fuse(h_sb) || !au_userns)
35 return 0;
36
37 ns = current->nsproxy;
38 /* no {get,put}_nsproxy(ns) */
39 return real_mount(mnt)->mnt_ns == ns->mnt_ns ? 0 : -EACCES;
40 }
41 #endif
42
43 /* ---------------------------------------------------------------------- */
44
45 int vfsub_update_h_iattr(struct path *h_path, int *did)
46 {
47 int err;
48 struct kstat st;
49 struct super_block *h_sb;
50
51 /* for remote fs, leave work for its getattr or d_revalidate */
52 /* for bad i_attr fs, handle them in aufs_getattr() */
53 /* still some fs may acquire i_mutex. we need to skip them */
54 err = 0;
55 if (!did)
56 did = &err;
57 h_sb = h_path->dentry->d_sb;
58 *did = (!au_test_fs_remote(h_sb) && au_test_fs_refresh_iattr(h_sb));
59 if (*did)
60 err = vfs_getattr(h_path, &st);
61
62 return err;
63 }
64
65 /* ---------------------------------------------------------------------- */
66
67 struct file *vfsub_dentry_open(struct path *path, int flags)
68 {
69 struct file *file;
70
71 file = dentry_open(path, flags /* | __FMODE_NONOTIFY */,
72 current_cred());
73 if (!IS_ERR_OR_NULL(file)
74 && (file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
75 i_readcount_inc(d_inode(path->dentry));
76
77 return file;
78 }
79
80 struct file *vfsub_filp_open(const char *path, int oflags, int mode)
81 {
82 struct file *file;
83
84 lockdep_off();
85 file = filp_open(path,
86 oflags /* | __FMODE_NONOTIFY */,
87 mode);
88 lockdep_on();
89 if (IS_ERR(file))
90 goto out;
91 vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
92
93 out:
94 return file;
95 }
96
97 /*
98 * Ideally this function should call VFS:do_last() in order to keep all its
99 * checkings. But it is very hard for aufs to regenerate several VFS internal
100 * structure such as nameidata. This is a second (or third) best approach.
101 * cf. linux/fs/namei.c:do_last(), lookup_open() and atomic_open().
102 */
103 int vfsub_atomic_open(struct inode *dir, struct dentry *dentry,
104 struct vfsub_aopen_args *args, struct au_branch *br)
105 {
106 int err;
107 struct file *file = args->file;
108 /* copied from linux/fs/namei.c:atomic_open() */
109 struct dentry *const DENTRY_NOT_SET = (void *)-1UL;
110
111 IMustLock(dir);
112 AuDebugOn(!dir->i_op->atomic_open);
113
114 err = au_br_test_oflag(args->open_flag, br);
115 if (unlikely(err))
116 goto out;
117
118 args->file->f_path.dentry = DENTRY_NOT_SET;
119 args->file->f_path.mnt = au_br_mnt(br);
120 err = dir->i_op->atomic_open(dir, dentry, file, args->open_flag,
121 args->create_mode, args->opened);
122 if (err >= 0) {
123 /* some filesystems don't set FILE_CREATED while succeeded? */
124 if (*args->opened & FILE_CREATED)
125 fsnotify_create(dir, dentry);
126 } else
127 goto out;
128
129
130 if (!err) {
131 /* todo: call VFS:may_open() here */
132 err = open_check_o_direct(file);
133 /* todo: ima_file_check() too? */
134 if (!err && (args->open_flag & __FMODE_EXEC))
135 err = deny_write_access(file);
136 if (unlikely(err))
137 /* note that the file is created and still opened */
138 goto out;
139 }
140
141 au_br_get(br);
142 fsnotify_open(file);
143
144 out:
145 return err;
146 }
147
148 int vfsub_kern_path(const char *name, unsigned int flags, struct path *path)
149 {
150 int err;
151
152 err = kern_path(name, flags, path);
153 if (!err && d_is_positive(path->dentry))
154 vfsub_update_h_iattr(path, /*did*/NULL); /*ignore*/
155 return err;
156 }
157
158 struct dentry *vfsub_lookup_one_len_unlocked(const char *name,
159 struct dentry *parent, int len)
160 {
161 struct path path = {
162 .mnt = NULL
163 };
164
165 path.dentry = lookup_one_len_unlocked(name, parent, len);
166 if (IS_ERR(path.dentry))
167 goto out;
168 if (d_is_positive(path.dentry))
169 vfsub_update_h_iattr(&path, /*did*/NULL); /*ignore*/
170
171 out:
172 AuTraceErrPtr(path.dentry);
173 return path.dentry;
174 }
175
176 struct dentry *vfsub_lookup_one_len(const char *name, struct dentry *parent,
177 int len)
178 {
179 struct path path = {
180 .mnt = NULL
181 };
182
183 /* VFS checks it too, but by WARN_ON_ONCE() */
184 IMustLock(d_inode(parent));
185
186 path.dentry = lookup_one_len(name, parent, len);
187 if (IS_ERR(path.dentry))
188 goto out;
189 if (d_is_positive(path.dentry))
190 vfsub_update_h_iattr(&path, /*did*/NULL); /*ignore*/
191
192 out:
193 AuTraceErrPtr(path.dentry);
194 return path.dentry;
195 }
196
197 void vfsub_call_lkup_one(void *args)
198 {
199 struct vfsub_lkup_one_args *a = args;
200 *a->errp = vfsub_lkup_one(a->name, a->parent);
201 }
202
203 /* ---------------------------------------------------------------------- */
204
205 struct dentry *vfsub_lock_rename(struct dentry *d1, struct au_hinode *hdir1,
206 struct dentry *d2, struct au_hinode *hdir2)
207 {
208 struct dentry *d;
209
210 lockdep_off();
211 d = lock_rename(d1, d2);
212 lockdep_on();
213 au_hn_suspend(hdir1);
214 if (hdir1 != hdir2)
215 au_hn_suspend(hdir2);
216
217 return d;
218 }
219
220 void vfsub_unlock_rename(struct dentry *d1, struct au_hinode *hdir1,
221 struct dentry *d2, struct au_hinode *hdir2)
222 {
223 au_hn_resume(hdir1);
224 if (hdir1 != hdir2)
225 au_hn_resume(hdir2);
226 lockdep_off();
227 unlock_rename(d1, d2);
228 lockdep_on();
229 }
230
231 /* ---------------------------------------------------------------------- */
232
233 int vfsub_create(struct inode *dir, struct path *path, int mode, bool want_excl)
234 {
235 int err;
236 struct dentry *d;
237
238 IMustLock(dir);
239
240 d = path->dentry;
241 path->dentry = d->d_parent;
242 err = security_path_mknod(path, d, mode, 0);
243 path->dentry = d;
244 if (unlikely(err))
245 goto out;
246
247 lockdep_off();
248 err = vfs_create(dir, path->dentry, mode, want_excl);
249 lockdep_on();
250 if (!err) {
251 struct path tmp = *path;
252 int did;
253
254 vfsub_update_h_iattr(&tmp, &did);
255 if (did) {
256 tmp.dentry = path->dentry->d_parent;
257 vfsub_update_h_iattr(&tmp, /*did*/NULL);
258 }
259 /*ignore*/
260 }
261
262 out:
263 return err;
264 }
265
266 int vfsub_symlink(struct inode *dir, struct path *path, const char *symname)
267 {
268 int err;
269 struct dentry *d;
270
271 IMustLock(dir);
272
273 d = path->dentry;
274 path->dentry = d->d_parent;
275 err = security_path_symlink(path, d, symname);
276 path->dentry = d;
277 if (unlikely(err))
278 goto out;
279
280 lockdep_off();
281 err = vfs_symlink(dir, path->dentry, symname);
282 lockdep_on();
283 if (!err) {
284 struct path tmp = *path;
285 int did;
286
287 vfsub_update_h_iattr(&tmp, &did);
288 if (did) {
289 tmp.dentry = path->dentry->d_parent;
290 vfsub_update_h_iattr(&tmp, /*did*/NULL);
291 }
292 /*ignore*/
293 }
294
295 out:
296 return err;
297 }
298
299 int vfsub_mknod(struct inode *dir, struct path *path, int mode, dev_t dev)
300 {
301 int err;
302 struct dentry *d;
303
304 IMustLock(dir);
305
306 d = path->dentry;
307 path->dentry = d->d_parent;
308 err = security_path_mknod(path, d, mode, new_encode_dev(dev));
309 path->dentry = d;
310 if (unlikely(err))
311 goto out;
312
313 lockdep_off();
314 err = vfs_mknod(dir, path->dentry, mode, dev);
315 lockdep_on();
316 if (!err) {
317 struct path tmp = *path;
318 int did;
319
320 vfsub_update_h_iattr(&tmp, &did);
321 if (did) {
322 tmp.dentry = path->dentry->d_parent;
323 vfsub_update_h_iattr(&tmp, /*did*/NULL);
324 }
325 /*ignore*/
326 }
327
328 out:
329 return err;
330 }
331
332 static int au_test_nlink(struct inode *inode)
333 {
334 const unsigned int link_max = UINT_MAX >> 1; /* rough margin */
335
336 if (!au_test_fs_no_limit_nlink(inode->i_sb)
337 || inode->i_nlink < link_max)
338 return 0;
339 return -EMLINK;
340 }
341
342 int vfsub_link(struct dentry *src_dentry, struct inode *dir, struct path *path,
343 struct inode **delegated_inode)
344 {
345 int err;
346 struct dentry *d;
347
348 IMustLock(dir);
349
350 err = au_test_nlink(d_inode(src_dentry));
351 if (unlikely(err))
352 return err;
353
354 /* we don't call may_linkat() */
355 d = path->dentry;
356 path->dentry = d->d_parent;
357 err = security_path_link(src_dentry, path, d);
358 path->dentry = d;
359 if (unlikely(err))
360 goto out;
361
362 lockdep_off();
363 err = vfs_link(src_dentry, dir, path->dentry, delegated_inode);
364 lockdep_on();
365 if (!err) {
366 struct path tmp = *path;
367 int did;
368
369 /* fuse has different memory inode for the same inumber */
370 vfsub_update_h_iattr(&tmp, &did);
371 if (did) {
372 tmp.dentry = path->dentry->d_parent;
373 vfsub_update_h_iattr(&tmp, /*did*/NULL);
374 tmp.dentry = src_dentry;
375 vfsub_update_h_iattr(&tmp, /*did*/NULL);
376 }
377 /*ignore*/
378 }
379
380 out:
381 return err;
382 }
383
384 int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
385 struct inode *dir, struct path *path,
386 struct inode **delegated_inode)
387 {
388 int err;
389 struct path tmp = {
390 .mnt = path->mnt
391 };
392 struct dentry *d;
393
394 IMustLock(dir);
395 IMustLock(src_dir);
396
397 d = path->dentry;
398 path->dentry = d->d_parent;
399 tmp.dentry = src_dentry->d_parent;
400 err = security_path_rename(&tmp, src_dentry, path, d, /*flags*/0);
401 path->dentry = d;
402 if (unlikely(err))
403 goto out;
404
405 lockdep_off();
406 err = vfs_rename(src_dir, src_dentry, dir, path->dentry,
407 delegated_inode, /*flags*/0);
408 lockdep_on();
409 if (!err) {
410 int did;
411
412 tmp.dentry = d->d_parent;
413 vfsub_update_h_iattr(&tmp, &did);
414 if (did) {
415 tmp.dentry = src_dentry;
416 vfsub_update_h_iattr(&tmp, /*did*/NULL);
417 tmp.dentry = src_dentry->d_parent;
418 vfsub_update_h_iattr(&tmp, /*did*/NULL);
419 }
420 /*ignore*/
421 }
422
423 out:
424 return err;
425 }
426
427 int vfsub_mkdir(struct inode *dir, struct path *path, int mode)
428 {
429 int err;
430 struct dentry *d;
431
432 IMustLock(dir);
433
434 d = path->dentry;
435 path->dentry = d->d_parent;
436 err = security_path_mkdir(path, d, mode);
437 path->dentry = d;
438 if (unlikely(err))
439 goto out;
440
441 lockdep_off();
442 err = vfs_mkdir(dir, path->dentry, mode);
443 lockdep_on();
444 if (!err) {
445 struct path tmp = *path;
446 int did;
447
448 vfsub_update_h_iattr(&tmp, &did);
449 if (did) {
450 tmp.dentry = path->dentry->d_parent;
451 vfsub_update_h_iattr(&tmp, /*did*/NULL);
452 }
453 /*ignore*/
454 }
455
456 out:
457 return err;
458 }
459
460 int vfsub_rmdir(struct inode *dir, struct path *path)
461 {
462 int err;
463 struct dentry *d;
464
465 IMustLock(dir);
466
467 d = path->dentry;
468 path->dentry = d->d_parent;
469 err = security_path_rmdir(path, d);
470 path->dentry = d;
471 if (unlikely(err))
472 goto out;
473
474 lockdep_off();
475 err = vfs_rmdir(dir, path->dentry);
476 lockdep_on();
477 if (!err) {
478 struct path tmp = {
479 .dentry = path->dentry->d_parent,
480 .mnt = path->mnt
481 };
482
483 vfsub_update_h_iattr(&tmp, /*did*/NULL); /*ignore*/
484 }
485
486 out:
487 return err;
488 }
489
490 /* ---------------------------------------------------------------------- */
491
492 /* todo: support mmap_sem? */
493 ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
494 loff_t *ppos)
495 {
496 ssize_t err;
497
498 lockdep_off();
499 err = vfs_read(file, ubuf, count, ppos);
500 lockdep_on();
501 if (err >= 0)
502 vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
503 return err;
504 }
505
506 /* todo: kernel_read()? */
507 ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count,
508 loff_t *ppos)
509 {
510 ssize_t err;
511 mm_segment_t oldfs;
512 union {
513 void *k;
514 char __user *u;
515 } buf;
516
517 buf.k = kbuf;
518 oldfs = get_fs();
519 set_fs(KERNEL_DS);
520 err = vfsub_read_u(file, buf.u, count, ppos);
521 set_fs(oldfs);
522 return err;
523 }
524
525 ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
526 loff_t *ppos)
527 {
528 ssize_t err;
529
530 lockdep_off();
531 err = vfs_write(file, ubuf, count, ppos);
532 lockdep_on();
533 if (err >= 0)
534 vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
535 return err;
536 }
537
538 ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos)
539 {
540 ssize_t err;
541 mm_segment_t oldfs;
542 union {
543 void *k;
544 const char __user *u;
545 } buf;
546
547 buf.k = kbuf;
548 oldfs = get_fs();
549 set_fs(KERNEL_DS);
550 err = vfsub_write_u(file, buf.u, count, ppos);
551 set_fs(oldfs);
552 return err;
553 }
554
555 int vfsub_flush(struct file *file, fl_owner_t id)
556 {
557 int err;
558
559 err = 0;
560 if (file->f_op->flush) {
561 if (!au_test_nfs(file->f_path.dentry->d_sb))
562 err = file->f_op->flush(file, id);
563 else {
564 lockdep_off();
565 err = file->f_op->flush(file, id);
566 lockdep_on();
567 }
568 if (!err)
569 vfsub_update_h_iattr(&file->f_path, /*did*/NULL);
570 /*ignore*/
571 }
572 return err;
573 }
574
575 int vfsub_iterate_dir(struct file *file, struct dir_context *ctx)
576 {
577 int err;
578
579 AuDbg("%pD, ctx{%pf, %llu}\n", file, ctx->actor, ctx->pos);
580
581 lockdep_off();
582 err = iterate_dir(file, ctx);
583 lockdep_on();
584 if (err >= 0)
585 vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
586 return err;
587 }
588
589 long vfsub_splice_to(struct file *in, loff_t *ppos,
590 struct pipe_inode_info *pipe, size_t len,
591 unsigned int flags)
592 {
593 long err;
594
595 lockdep_off();
596 err = do_splice_to(in, ppos, pipe, len, flags);
597 lockdep_on();
598 file_accessed(in);
599 if (err >= 0)
600 vfsub_update_h_iattr(&in->f_path, /*did*/NULL); /*ignore*/
601 return err;
602 }
603
604 long vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
605 loff_t *ppos, size_t len, unsigned int flags)
606 {
607 long err;
608
609 lockdep_off();
610 err = do_splice_from(pipe, out, ppos, len, flags);
611 lockdep_on();
612 if (err >= 0)
613 vfsub_update_h_iattr(&out->f_path, /*did*/NULL); /*ignore*/
614 return err;
615 }
616
617 int vfsub_fsync(struct file *file, struct path *path, int datasync)
618 {
619 int err;
620
621 /* file can be NULL */
622 lockdep_off();
623 err = vfs_fsync(file, datasync);
624 lockdep_on();
625 if (!err) {
626 if (!path) {
627 AuDebugOn(!file);
628 path = &file->f_path;
629 }
630 vfsub_update_h_iattr(path, /*did*/NULL); /*ignore*/
631 }
632 return err;
633 }
634
635 /* cf. open.c:do_sys_truncate() and do_sys_ftruncate() */
636 int vfsub_trunc(struct path *h_path, loff_t length, unsigned int attr,
637 struct file *h_file)
638 {
639 int err;
640 struct inode *h_inode;
641 struct super_block *h_sb;
642
643 if (!h_file) {
644 err = vfsub_truncate(h_path, length);
645 goto out;
646 }
647
648 h_inode = d_inode(h_path->dentry);
649 h_sb = h_inode->i_sb;
650 lockdep_off();
651 sb_start_write(h_sb);
652 lockdep_on();
653 err = locks_verify_truncate(h_inode, h_file, length);
654 if (!err)
655 err = security_path_truncate(h_path);
656 if (!err) {
657 lockdep_off();
658 err = do_truncate(h_path->dentry, length, attr, h_file);
659 lockdep_on();
660 }
661 lockdep_off();
662 sb_end_write(h_sb);
663 lockdep_on();
664
665 out:
666 return err;
667 }
668
669 /* ---------------------------------------------------------------------- */
670
671 struct au_vfsub_mkdir_args {
672 int *errp;
673 struct inode *dir;
674 struct path *path;
675 int mode;
676 };
677
678 static void au_call_vfsub_mkdir(void *args)
679 {
680 struct au_vfsub_mkdir_args *a = args;
681 *a->errp = vfsub_mkdir(a->dir, a->path, a->mode);
682 }
683
684 int vfsub_sio_mkdir(struct inode *dir, struct path *path, int mode)
685 {
686 int err, do_sio, wkq_err;
687
688 do_sio = au_test_h_perm_sio(dir, MAY_EXEC | MAY_WRITE);
689 if (!do_sio) {
690 lockdep_off();
691 err = vfsub_mkdir(dir, path, mode);
692 lockdep_on();
693 } else {
694 struct au_vfsub_mkdir_args args = {
695 .errp = &err,
696 .dir = dir,
697 .path = path,
698 .mode = mode
699 };
700 wkq_err = au_wkq_wait(au_call_vfsub_mkdir, &args);
701 if (unlikely(wkq_err))
702 err = wkq_err;
703 }
704
705 return err;
706 }
707
708 struct au_vfsub_rmdir_args {
709 int *errp;
710 struct inode *dir;
711 struct path *path;
712 };
713
714 static void au_call_vfsub_rmdir(void *args)
715 {
716 struct au_vfsub_rmdir_args *a = args;
717 *a->errp = vfsub_rmdir(a->dir, a->path);
718 }
719
720 int vfsub_sio_rmdir(struct inode *dir, struct path *path)
721 {
722 int err, do_sio, wkq_err;
723
724 do_sio = au_test_h_perm_sio(dir, MAY_EXEC | MAY_WRITE);
725 if (!do_sio) {
726 lockdep_off();
727 err = vfsub_rmdir(dir, path);
728 lockdep_on();
729 } else {
730 struct au_vfsub_rmdir_args args = {
731 .errp = &err,
732 .dir = dir,
733 .path = path
734 };
735 wkq_err = au_wkq_wait(au_call_vfsub_rmdir, &args);
736 if (unlikely(wkq_err))
737 err = wkq_err;
738 }
739
740 return err;
741 }
742
743 /* ---------------------------------------------------------------------- */
744
745 struct notify_change_args {
746 int *errp;
747 struct path *path;
748 struct iattr *ia;
749 struct inode **delegated_inode;
750 };
751
752 static void call_notify_change(void *args)
753 {
754 struct notify_change_args *a = args;
755 struct inode *h_inode;
756
757 h_inode = d_inode(a->path->dentry);
758 IMustLock(h_inode);
759
760 *a->errp = -EPERM;
761 if (!IS_IMMUTABLE(h_inode) && !IS_APPEND(h_inode)) {
762 lockdep_off();
763 *a->errp = notify_change(a->path->dentry, a->ia,
764 a->delegated_inode);
765 lockdep_on();
766 if (!*a->errp)
767 vfsub_update_h_iattr(a->path, /*did*/NULL); /*ignore*/
768 }
769 AuTraceErr(*a->errp);
770 }
771
772 int vfsub_notify_change(struct path *path, struct iattr *ia,
773 struct inode **delegated_inode)
774 {
775 int err;
776 struct notify_change_args args = {
777 .errp = &err,
778 .path = path,
779 .ia = ia,
780 .delegated_inode = delegated_inode
781 };
782
783 call_notify_change(&args);
784
785 return err;
786 }
787
788 int vfsub_sio_notify_change(struct path *path, struct iattr *ia,
789 struct inode **delegated_inode)
790 {
791 int err, wkq_err;
792 struct notify_change_args args = {
793 .errp = &err,
794 .path = path,
795 .ia = ia,
796 .delegated_inode = delegated_inode
797 };
798
799 wkq_err = au_wkq_wait(call_notify_change, &args);
800 if (unlikely(wkq_err))
801 err = wkq_err;
802
803 return err;
804 }
805
806 /* ---------------------------------------------------------------------- */
807
808 struct unlink_args {
809 int *errp;
810 struct inode *dir;
811 struct path *path;
812 struct inode **delegated_inode;
813 };
814
815 static void call_unlink(void *args)
816 {
817 struct unlink_args *a = args;
818 struct dentry *d = a->path->dentry;
819 struct inode *h_inode;
820 const int stop_sillyrename = (au_test_nfs(d->d_sb)
821 && au_dcount(d) == 1);
822
823 IMustLock(a->dir);
824
825 a->path->dentry = d->d_parent;
826 *a->errp = security_path_unlink(a->path, d);
827 a->path->dentry = d;
828 if (unlikely(*a->errp))
829 return;
830
831 if (!stop_sillyrename)
832 dget(d);
833 h_inode = NULL;
834 if (d_is_positive(d)) {
835 h_inode = d_inode(d);
836 ihold(h_inode);
837 }
838
839 lockdep_off();
840 *a->errp = vfs_unlink(a->dir, d, a->delegated_inode);
841 lockdep_on();
842 if (!*a->errp) {
843 struct path tmp = {
844 .dentry = d->d_parent,
845 .mnt = a->path->mnt
846 };
847 vfsub_update_h_iattr(&tmp, /*did*/NULL); /*ignore*/
848 }
849
850 if (!stop_sillyrename)
851 dput(d);
852 if (h_inode)
853 iput(h_inode);
854
855 AuTraceErr(*a->errp);
856 }
857
858 /*
859 * @dir: must be locked.
860 * @dentry: target dentry.
861 */
862 int vfsub_unlink(struct inode *dir, struct path *path,
863 struct inode **delegated_inode, int force)
864 {
865 int err;
866 struct unlink_args args = {
867 .errp = &err,
868 .dir = dir,
869 .path = path,
870 .delegated_inode = delegated_inode
871 };
872
873 if (!force)
874 call_unlink(&args);
875 else {
876 int wkq_err;
877
878 wkq_err = au_wkq_wait(call_unlink, &args);
879 if (unlikely(wkq_err))
880 err = wkq_err;
881 }
882
883 return err;
884 }