]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/aufs/xino.c
x86/mm: Add TLB purge to free pmd/pte page interfaces
[mirror_ubuntu-bionic-kernel.git] / fs / aufs / xino.c
1 /*
2 * Copyright (C) 2005-2017 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 * external inode number translation table and bitmap
20 */
21
22 #include <linux/seq_file.h>
23 #include <linux/statfs.h>
24 #include "aufs.h"
25
26 static ssize_t xino_fread_wkq(vfs_readf_t func, struct file *file, void *buf,
27 size_t size, loff_t *pos);
28
29 /* todo: unnecessary to support mmap_sem since kernel-space? */
30 ssize_t xino_fread(vfs_readf_t func, struct file *file, void *kbuf, size_t size,
31 loff_t *pos)
32 {
33 ssize_t err;
34 mm_segment_t oldfs;
35 union {
36 void *k;
37 char __user *u;
38 } buf;
39 int i;
40 const int prevent_endless = 10;
41
42 i = 0;
43 buf.k = kbuf;
44 oldfs = get_fs();
45 set_fs(KERNEL_DS);
46 do {
47 err = func(file, buf.u, size, pos);
48 if (err == -EINTR
49 && !au_wkq_test()
50 && fatal_signal_pending(current)) {
51 set_fs(oldfs);
52 err = xino_fread_wkq(func, file, kbuf, size, pos);
53 BUG_ON(err == -EINTR);
54 oldfs = get_fs();
55 set_fs(KERNEL_DS);
56 }
57 } while (i++ < prevent_endless
58 && (err == -EAGAIN || err == -EINTR));
59 set_fs(oldfs);
60
61 #if 0 /* reserved for future use */
62 if (err > 0)
63 fsnotify_access(file->f_path.dentry);
64 #endif
65
66 return err;
67 }
68
69 struct xino_fread_args {
70 ssize_t *errp;
71 vfs_readf_t func;
72 struct file *file;
73 void *buf;
74 size_t size;
75 loff_t *pos;
76 };
77
78 static void call_xino_fread(void *args)
79 {
80 struct xino_fread_args *a = args;
81 *a->errp = xino_fread(a->func, a->file, a->buf, a->size, a->pos);
82 }
83
84 static ssize_t xino_fread_wkq(vfs_readf_t func, struct file *file, void *buf,
85 size_t size, loff_t *pos)
86 {
87 ssize_t err;
88 int wkq_err;
89 struct xino_fread_args args = {
90 .errp = &err,
91 .func = func,
92 .file = file,
93 .buf = buf,
94 .size = size,
95 .pos = pos
96 };
97
98 wkq_err = au_wkq_wait(call_xino_fread, &args);
99 if (unlikely(wkq_err))
100 err = wkq_err;
101
102 return err;
103 }
104
105 /* ---------------------------------------------------------------------- */
106
107 static ssize_t xino_fwrite_wkq(vfs_writef_t func, struct file *file, void *buf,
108 size_t size, loff_t *pos);
109
110 static ssize_t do_xino_fwrite(vfs_writef_t func, struct file *file, void *kbuf,
111 size_t size, loff_t *pos)
112 {
113 ssize_t err;
114 mm_segment_t oldfs;
115 union {
116 void *k;
117 const char __user *u;
118 } buf;
119 int i;
120 const int prevent_endless = 10;
121
122 i = 0;
123 buf.k = kbuf;
124 oldfs = get_fs();
125 set_fs(KERNEL_DS);
126 do {
127 err = func(file, buf.u, size, pos);
128 if (err == -EINTR
129 && !au_wkq_test()
130 && fatal_signal_pending(current)) {
131 set_fs(oldfs);
132 err = xino_fwrite_wkq(func, file, kbuf, size, pos);
133 BUG_ON(err == -EINTR);
134 oldfs = get_fs();
135 set_fs(KERNEL_DS);
136 }
137 } while (i++ < prevent_endless
138 && (err == -EAGAIN || err == -EINTR));
139 set_fs(oldfs);
140
141 #if 0 /* reserved for future use */
142 if (err > 0)
143 fsnotify_modify(file->f_path.dentry);
144 #endif
145
146 return err;
147 }
148
149 struct do_xino_fwrite_args {
150 ssize_t *errp;
151 vfs_writef_t func;
152 struct file *file;
153 void *buf;
154 size_t size;
155 loff_t *pos;
156 };
157
158 static void call_do_xino_fwrite(void *args)
159 {
160 struct do_xino_fwrite_args *a = args;
161 *a->errp = do_xino_fwrite(a->func, a->file, a->buf, a->size, a->pos);
162 }
163
164 static ssize_t xino_fwrite_wkq(vfs_writef_t func, struct file *file, void *buf,
165 size_t size, loff_t *pos)
166 {
167 ssize_t err;
168 int wkq_err;
169 struct do_xino_fwrite_args args = {
170 .errp = &err,
171 .func = func,
172 .file = file,
173 .buf = buf,
174 .size = size,
175 .pos = pos
176 };
177
178 /*
179 * it breaks RLIMIT_FSIZE and normal user's limit,
180 * users should care about quota and real 'filesystem full.'
181 */
182 wkq_err = au_wkq_wait(call_do_xino_fwrite, &args);
183 if (unlikely(wkq_err))
184 err = wkq_err;
185
186 return err;
187 }
188
189 ssize_t xino_fwrite(vfs_writef_t func, struct file *file, void *buf,
190 size_t size, loff_t *pos)
191 {
192 ssize_t err;
193
194 if (rlimit(RLIMIT_FSIZE) == RLIM_INFINITY) {
195 lockdep_off();
196 err = do_xino_fwrite(func, file, buf, size, pos);
197 lockdep_on();
198 } else {
199 lockdep_off();
200 err = xino_fwrite_wkq(func, file, buf, size, pos);
201 lockdep_on();
202 }
203
204 return err;
205 }
206
207 /* ---------------------------------------------------------------------- */
208
209 /*
210 * create a new xinofile at the same place/path as @base_file.
211 */
212 struct file *au_xino_create2(struct file *base_file, struct file *copy_src)
213 {
214 struct file *file;
215 struct dentry *base, *parent;
216 struct inode *dir, *delegated;
217 struct qstr *name;
218 struct path path;
219 int err;
220
221 base = base_file->f_path.dentry;
222 parent = base->d_parent; /* dir inode is locked */
223 dir = d_inode(parent);
224 IMustLock(dir);
225
226 file = ERR_PTR(-EINVAL);
227 name = &base->d_name;
228 path.dentry = vfsub_lookup_one_len(name->name, parent, name->len);
229 if (IS_ERR(path.dentry)) {
230 file = (void *)path.dentry;
231 pr_err("%pd lookup err %ld\n",
232 base, PTR_ERR(path.dentry));
233 goto out;
234 }
235
236 /* no need to mnt_want_write() since we call dentry_open() later */
237 err = vfs_create(dir, path.dentry, S_IRUGO | S_IWUGO, NULL);
238 if (unlikely(err)) {
239 file = ERR_PTR(err);
240 pr_err("%pd create err %d\n", base, err);
241 goto out_dput;
242 }
243
244 path.mnt = base_file->f_path.mnt;
245 file = vfsub_dentry_open(&path,
246 O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE
247 /* | __FMODE_NONOTIFY */);
248 if (IS_ERR(file)) {
249 pr_err("%pd open err %ld\n", base, PTR_ERR(file));
250 goto out_dput;
251 }
252
253 delegated = NULL;
254 err = vfsub_unlink(dir, &file->f_path, &delegated, /*force*/0);
255 if (unlikely(err == -EWOULDBLOCK)) {
256 pr_warn("cannot retry for NFSv4 delegation"
257 " for an internal unlink\n");
258 iput(delegated);
259 }
260 if (unlikely(err)) {
261 pr_err("%pd unlink err %d\n", base, err);
262 goto out_fput;
263 }
264
265 if (copy_src) {
266 /* no one can touch copy_src xino */
267 err = au_copy_file(file, copy_src, vfsub_f_size_read(copy_src));
268 if (unlikely(err)) {
269 pr_err("%pd copy err %d\n", base, err);
270 goto out_fput;
271 }
272 }
273 goto out_dput; /* success */
274
275 out_fput:
276 fput(file);
277 file = ERR_PTR(err);
278 out_dput:
279 dput(path.dentry);
280 out:
281 return file;
282 }
283
284 struct au_xino_lock_dir {
285 struct au_hinode *hdir;
286 struct dentry *parent;
287 struct inode *dir;
288 };
289
290 static void au_xino_lock_dir(struct super_block *sb, struct file *xino,
291 struct au_xino_lock_dir *ldir)
292 {
293 aufs_bindex_t brid, bindex;
294
295 ldir->hdir = NULL;
296 bindex = -1;
297 brid = au_xino_brid(sb);
298 if (brid >= 0)
299 bindex = au_br_index(sb, brid);
300 if (bindex >= 0) {
301 ldir->hdir = au_hi(d_inode(sb->s_root), bindex);
302 au_hn_inode_lock_nested(ldir->hdir, AuLsc_I_PARENT);
303 } else {
304 ldir->parent = dget_parent(xino->f_path.dentry);
305 ldir->dir = d_inode(ldir->parent);
306 inode_lock_nested(ldir->dir, AuLsc_I_PARENT);
307 }
308 }
309
310 static void au_xino_unlock_dir(struct au_xino_lock_dir *ldir)
311 {
312 if (ldir->hdir)
313 au_hn_inode_unlock(ldir->hdir);
314 else {
315 inode_unlock(ldir->dir);
316 dput(ldir->parent);
317 }
318 }
319
320 /* ---------------------------------------------------------------------- */
321
322 /* trucate xino files asynchronously */
323
324 int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex)
325 {
326 int err;
327 unsigned long jiffy;
328 blkcnt_t blocks;
329 aufs_bindex_t bi, bbot;
330 struct kstatfs *st;
331 struct au_branch *br;
332 struct file *new_xino, *file;
333 struct super_block *h_sb;
334 struct au_xino_lock_dir ldir;
335
336 err = -ENOMEM;
337 st = kmalloc(sizeof(*st), GFP_NOFS);
338 if (unlikely(!st))
339 goto out;
340
341 err = -EINVAL;
342 bbot = au_sbbot(sb);
343 if (unlikely(bindex < 0 || bbot < bindex))
344 goto out_st;
345 br = au_sbr(sb, bindex);
346 file = br->br_xino.xi_file;
347 if (!file)
348 goto out_st;
349
350 err = vfs_statfs(&file->f_path, st);
351 if (unlikely(err))
352 AuErr1("statfs err %d, ignored\n", err);
353 jiffy = jiffies;
354 blocks = file_inode(file)->i_blocks;
355 pr_info("begin truncating xino(b%d), ib%llu, %llu/%llu free blks\n",
356 bindex, (u64)blocks, st->f_bfree, st->f_blocks);
357
358 au_xino_lock_dir(sb, file, &ldir);
359 /* mnt_want_write() is unnecessary here */
360 new_xino = au_xino_create2(file, file);
361 au_xino_unlock_dir(&ldir);
362 err = PTR_ERR(new_xino);
363 if (IS_ERR(new_xino)) {
364 pr_err("err %d, ignored\n", err);
365 goto out_st;
366 }
367 err = 0;
368 fput(file);
369 br->br_xino.xi_file = new_xino;
370
371 h_sb = au_br_sb(br);
372 for (bi = 0; bi <= bbot; bi++) {
373 if (unlikely(bi == bindex))
374 continue;
375 br = au_sbr(sb, bi);
376 if (au_br_sb(br) != h_sb)
377 continue;
378
379 fput(br->br_xino.xi_file);
380 br->br_xino.xi_file = new_xino;
381 get_file(new_xino);
382 }
383
384 err = vfs_statfs(&new_xino->f_path, st);
385 if (!err) {
386 pr_info("end truncating xino(b%d), ib%llu, %llu/%llu free blks\n",
387 bindex, (u64)file_inode(new_xino)->i_blocks,
388 st->f_bfree, st->f_blocks);
389 if (file_inode(new_xino)->i_blocks < blocks)
390 au_sbi(sb)->si_xino_jiffy = jiffy;
391 } else
392 AuErr1("statfs err %d, ignored\n", err);
393
394 out_st:
395 kfree(st);
396 out:
397 return err;
398 }
399
400 struct xino_do_trunc_args {
401 struct super_block *sb;
402 struct au_branch *br;
403 };
404
405 static void xino_do_trunc(void *_args)
406 {
407 struct xino_do_trunc_args *args = _args;
408 struct super_block *sb;
409 struct au_branch *br;
410 struct inode *dir;
411 int err;
412 aufs_bindex_t bindex;
413
414 err = 0;
415 sb = args->sb;
416 dir = d_inode(sb->s_root);
417 br = args->br;
418
419 si_noflush_write_lock(sb);
420 ii_read_lock_parent(dir);
421 bindex = au_br_index(sb, br->br_id);
422 err = au_xino_trunc(sb, bindex);
423 ii_read_unlock(dir);
424 if (unlikely(err))
425 pr_warn("err b%d, (%d)\n", bindex, err);
426 atomic_dec(&br->br_xino_running);
427 au_br_put(br);
428 si_write_unlock(sb);
429 au_nwt_done(&au_sbi(sb)->si_nowait);
430 kfree(args);
431 }
432
433 static int xino_trunc_test(struct super_block *sb, struct au_branch *br)
434 {
435 int err;
436 struct kstatfs st;
437 struct au_sbinfo *sbinfo;
438
439 /* todo: si_xino_expire and the ratio should be customizable */
440 sbinfo = au_sbi(sb);
441 if (time_before(jiffies,
442 sbinfo->si_xino_jiffy + sbinfo->si_xino_expire))
443 return 0;
444
445 /* truncation border */
446 err = vfs_statfs(&br->br_xino.xi_file->f_path, &st);
447 if (unlikely(err)) {
448 AuErr1("statfs err %d, ignored\n", err);
449 return 0;
450 }
451 if (div64_u64(st.f_bfree * 100, st.f_blocks) >= AUFS_XINO_DEF_TRUNC)
452 return 0;
453
454 return 1;
455 }
456
457 static void xino_try_trunc(struct super_block *sb, struct au_branch *br)
458 {
459 struct xino_do_trunc_args *args;
460 int wkq_err;
461
462 if (!xino_trunc_test(sb, br))
463 return;
464
465 if (atomic_inc_return(&br->br_xino_running) > 1)
466 goto out;
467
468 /* lock and kfree() will be called in trunc_xino() */
469 args = kmalloc(sizeof(*args), GFP_NOFS);
470 if (unlikely(!args)) {
471 AuErr1("no memory\n");
472 goto out;
473 }
474
475 au_br_get(br);
476 args->sb = sb;
477 args->br = br;
478 wkq_err = au_wkq_nowait(xino_do_trunc, args, sb, /*flags*/0);
479 if (!wkq_err)
480 return; /* success */
481
482 pr_err("wkq %d\n", wkq_err);
483 au_br_put(br);
484 kfree(args);
485
486 out:
487 atomic_dec(&br->br_xino_running);
488 }
489
490 /* ---------------------------------------------------------------------- */
491
492 static int au_xino_do_write(vfs_writef_t write, struct file *file,
493 ino_t h_ino, ino_t ino)
494 {
495 loff_t pos;
496 ssize_t sz;
497
498 pos = h_ino;
499 if (unlikely(au_loff_max / sizeof(ino) - 1 < pos)) {
500 AuIOErr1("too large hi%lu\n", (unsigned long)h_ino);
501 return -EFBIG;
502 }
503 pos *= sizeof(ino);
504 sz = xino_fwrite(write, file, &ino, sizeof(ino), &pos);
505 if (sz == sizeof(ino))
506 return 0; /* success */
507
508 AuIOErr("write failed (%zd)\n", sz);
509 return -EIO;
510 }
511
512 /*
513 * write @ino to the xinofile for the specified branch{@sb, @bindex}
514 * at the position of @h_ino.
515 * even if @ino is zero, it is written to the xinofile and means no entry.
516 * if the size of the xino file on a specific filesystem exceeds the watermark,
517 * try truncating it.
518 */
519 int au_xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
520 ino_t ino)
521 {
522 int err;
523 unsigned int mnt_flags;
524 struct au_branch *br;
525
526 BUILD_BUG_ON(sizeof(long long) != sizeof(au_loff_max)
527 || ((loff_t)-1) > 0);
528 SiMustAnyLock(sb);
529
530 mnt_flags = au_mntflags(sb);
531 if (!au_opt_test(mnt_flags, XINO))
532 return 0;
533
534 br = au_sbr(sb, bindex);
535 err = au_xino_do_write(au_sbi(sb)->si_xwrite, br->br_xino.xi_file,
536 h_ino, ino);
537 if (!err) {
538 if (au_opt_test(mnt_flags, TRUNC_XINO)
539 && au_test_fs_trunc_xino(au_br_sb(br)))
540 xino_try_trunc(sb, br);
541 return 0; /* success */
542 }
543
544 AuIOErr("write failed (%d)\n", err);
545 return -EIO;
546 }
547
548 /* ---------------------------------------------------------------------- */
549
550 /* aufs inode number bitmap */
551
552 static const int page_bits = (int)PAGE_SIZE * BITS_PER_BYTE;
553 static ino_t xib_calc_ino(unsigned long pindex, int bit)
554 {
555 ino_t ino;
556
557 AuDebugOn(bit < 0 || page_bits <= bit);
558 ino = AUFS_FIRST_INO + pindex * page_bits + bit;
559 return ino;
560 }
561
562 static void xib_calc_bit(ino_t ino, unsigned long *pindex, int *bit)
563 {
564 AuDebugOn(ino < AUFS_FIRST_INO);
565 ino -= AUFS_FIRST_INO;
566 *pindex = ino / page_bits;
567 *bit = ino % page_bits;
568 }
569
570 static int xib_pindex(struct super_block *sb, unsigned long pindex)
571 {
572 int err;
573 loff_t pos;
574 ssize_t sz;
575 struct au_sbinfo *sbinfo;
576 struct file *xib;
577 unsigned long *p;
578
579 sbinfo = au_sbi(sb);
580 MtxMustLock(&sbinfo->si_xib_mtx);
581 AuDebugOn(pindex > ULONG_MAX / PAGE_SIZE
582 || !au_opt_test(sbinfo->si_mntflags, XINO));
583
584 if (pindex == sbinfo->si_xib_last_pindex)
585 return 0;
586
587 xib = sbinfo->si_xib;
588 p = sbinfo->si_xib_buf;
589 pos = sbinfo->si_xib_last_pindex;
590 pos *= PAGE_SIZE;
591 sz = xino_fwrite(sbinfo->si_xwrite, xib, p, PAGE_SIZE, &pos);
592 if (unlikely(sz != PAGE_SIZE))
593 goto out;
594
595 pos = pindex;
596 pos *= PAGE_SIZE;
597 if (vfsub_f_size_read(xib) >= pos + PAGE_SIZE)
598 sz = xino_fread(sbinfo->si_xread, xib, p, PAGE_SIZE, &pos);
599 else {
600 memset(p, 0, PAGE_SIZE);
601 sz = xino_fwrite(sbinfo->si_xwrite, xib, p, PAGE_SIZE, &pos);
602 }
603 if (sz == PAGE_SIZE) {
604 sbinfo->si_xib_last_pindex = pindex;
605 return 0; /* success */
606 }
607
608 out:
609 AuIOErr1("write failed (%zd)\n", sz);
610 err = sz;
611 if (sz >= 0)
612 err = -EIO;
613 return err;
614 }
615
616 /* ---------------------------------------------------------------------- */
617
618 static void au_xib_clear_bit(struct inode *inode)
619 {
620 int err, bit;
621 unsigned long pindex;
622 struct super_block *sb;
623 struct au_sbinfo *sbinfo;
624
625 AuDebugOn(inode->i_nlink);
626
627 sb = inode->i_sb;
628 xib_calc_bit(inode->i_ino, &pindex, &bit);
629 AuDebugOn(page_bits <= bit);
630 sbinfo = au_sbi(sb);
631 mutex_lock(&sbinfo->si_xib_mtx);
632 err = xib_pindex(sb, pindex);
633 if (!err) {
634 clear_bit(bit, sbinfo->si_xib_buf);
635 sbinfo->si_xib_next_bit = bit;
636 }
637 mutex_unlock(&sbinfo->si_xib_mtx);
638 }
639
640 /* for s_op->delete_inode() */
641 void au_xino_delete_inode(struct inode *inode, const int unlinked)
642 {
643 int err;
644 unsigned int mnt_flags;
645 aufs_bindex_t bindex, bbot, bi;
646 unsigned char try_trunc;
647 struct au_iinfo *iinfo;
648 struct super_block *sb;
649 struct au_hinode *hi;
650 struct inode *h_inode;
651 struct au_branch *br;
652 vfs_writef_t xwrite;
653
654 AuDebugOn(au_is_bad_inode(inode));
655
656 sb = inode->i_sb;
657 mnt_flags = au_mntflags(sb);
658 if (!au_opt_test(mnt_flags, XINO)
659 || inode->i_ino == AUFS_ROOT_INO)
660 return;
661
662 if (unlinked) {
663 au_xigen_inc(inode);
664 au_xib_clear_bit(inode);
665 }
666
667 iinfo = au_ii(inode);
668 bindex = iinfo->ii_btop;
669 if (bindex < 0)
670 return;
671
672 xwrite = au_sbi(sb)->si_xwrite;
673 try_trunc = !!au_opt_test(mnt_flags, TRUNC_XINO);
674 hi = au_hinode(iinfo, bindex);
675 bbot = iinfo->ii_bbot;
676 for (; bindex <= bbot; bindex++, hi++) {
677 h_inode = hi->hi_inode;
678 if (!h_inode
679 || (!unlinked && h_inode->i_nlink))
680 continue;
681
682 /* inode may not be revalidated */
683 bi = au_br_index(sb, hi->hi_id);
684 if (bi < 0)
685 continue;
686
687 br = au_sbr(sb, bi);
688 err = au_xino_do_write(xwrite, br->br_xino.xi_file,
689 h_inode->i_ino, /*ino*/0);
690 if (!err && try_trunc
691 && au_test_fs_trunc_xino(au_br_sb(br)))
692 xino_try_trunc(sb, br);
693 }
694 }
695
696 /* get an unused inode number from bitmap */
697 ino_t au_xino_new_ino(struct super_block *sb)
698 {
699 ino_t ino;
700 unsigned long *p, pindex, ul, pend;
701 struct au_sbinfo *sbinfo;
702 struct file *file;
703 int free_bit, err;
704
705 if (!au_opt_test(au_mntflags(sb), XINO))
706 return iunique(sb, AUFS_FIRST_INO);
707
708 sbinfo = au_sbi(sb);
709 mutex_lock(&sbinfo->si_xib_mtx);
710 p = sbinfo->si_xib_buf;
711 free_bit = sbinfo->si_xib_next_bit;
712 if (free_bit < page_bits && !test_bit(free_bit, p))
713 goto out; /* success */
714 free_bit = find_first_zero_bit(p, page_bits);
715 if (free_bit < page_bits)
716 goto out; /* success */
717
718 pindex = sbinfo->si_xib_last_pindex;
719 for (ul = pindex - 1; ul < ULONG_MAX; ul--) {
720 err = xib_pindex(sb, ul);
721 if (unlikely(err))
722 goto out_err;
723 free_bit = find_first_zero_bit(p, page_bits);
724 if (free_bit < page_bits)
725 goto out; /* success */
726 }
727
728 file = sbinfo->si_xib;
729 pend = vfsub_f_size_read(file) / PAGE_SIZE;
730 for (ul = pindex + 1; ul <= pend; ul++) {
731 err = xib_pindex(sb, ul);
732 if (unlikely(err))
733 goto out_err;
734 free_bit = find_first_zero_bit(p, page_bits);
735 if (free_bit < page_bits)
736 goto out; /* success */
737 }
738 BUG();
739
740 out:
741 set_bit(free_bit, p);
742 sbinfo->si_xib_next_bit = free_bit + 1;
743 pindex = sbinfo->si_xib_last_pindex;
744 mutex_unlock(&sbinfo->si_xib_mtx);
745 ino = xib_calc_ino(pindex, free_bit);
746 AuDbg("i%lu\n", (unsigned long)ino);
747 return ino;
748 out_err:
749 mutex_unlock(&sbinfo->si_xib_mtx);
750 AuDbg("i0\n");
751 return 0;
752 }
753
754 /*
755 * read @ino from xinofile for the specified branch{@sb, @bindex}
756 * at the position of @h_ino.
757 * if @ino does not exist and @do_new is true, get new one.
758 */
759 int au_xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
760 ino_t *ino)
761 {
762 int err;
763 ssize_t sz;
764 loff_t pos;
765 struct file *file;
766 struct au_sbinfo *sbinfo;
767
768 *ino = 0;
769 if (!au_opt_test(au_mntflags(sb), XINO))
770 return 0; /* no xino */
771
772 err = 0;
773 sbinfo = au_sbi(sb);
774 pos = h_ino;
775 if (unlikely(au_loff_max / sizeof(*ino) - 1 < pos)) {
776 AuIOErr1("too large hi%lu\n", (unsigned long)h_ino);
777 return -EFBIG;
778 }
779 pos *= sizeof(*ino);
780
781 file = au_sbr(sb, bindex)->br_xino.xi_file;
782 if (vfsub_f_size_read(file) < pos + sizeof(*ino))
783 return 0; /* no ino */
784
785 sz = xino_fread(sbinfo->si_xread, file, ino, sizeof(*ino), &pos);
786 if (sz == sizeof(*ino))
787 return 0; /* success */
788
789 err = sz;
790 if (unlikely(sz >= 0)) {
791 err = -EIO;
792 AuIOErr("xino read error (%zd)\n", sz);
793 }
794
795 return err;
796 }
797
798 /* ---------------------------------------------------------------------- */
799
800 /* create and set a new xino file */
801
802 struct file *au_xino_create(struct super_block *sb, char *fname, int silent)
803 {
804 struct file *file;
805 struct dentry *h_parent, *d;
806 struct inode *h_dir, *inode;
807 int err;
808
809 /*
810 * at mount-time, and the xino file is the default path,
811 * hnotify is disabled so we have no notify events to ignore.
812 * when a user specified the xino, we cannot get au_hdir to be ignored.
813 */
814 file = vfsub_filp_open(fname, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE
815 /* | __FMODE_NONOTIFY */,
816 S_IRUGO | S_IWUGO);
817 if (IS_ERR(file)) {
818 if (!silent)
819 pr_err("open %s(%ld)\n", fname, PTR_ERR(file));
820 return file;
821 }
822
823 /* keep file count */
824 err = 0;
825 inode = file_inode(file);
826 h_parent = dget_parent(file->f_path.dentry);
827 h_dir = d_inode(h_parent);
828 inode_lock_nested(h_dir, AuLsc_I_PARENT);
829 /* mnt_want_write() is unnecessary here */
830 /* no delegation since it is just created */
831 if (inode->i_nlink)
832 err = vfsub_unlink(h_dir, &file->f_path, /*delegated*/NULL,
833 /*force*/0);
834 inode_unlock(h_dir);
835 dput(h_parent);
836 if (unlikely(err)) {
837 if (!silent)
838 pr_err("unlink %s(%d)\n", fname, err);
839 goto out;
840 }
841
842 err = -EINVAL;
843 d = file->f_path.dentry;
844 if (unlikely(sb == d->d_sb)) {
845 if (!silent)
846 pr_err("%s must be outside\n", fname);
847 goto out;
848 }
849 if (unlikely(au_test_fs_bad_xino(d->d_sb))) {
850 if (!silent)
851 pr_err("xino doesn't support %s(%s)\n",
852 fname, au_sbtype(d->d_sb));
853 goto out;
854 }
855 return file; /* success */
856
857 out:
858 fput(file);
859 file = ERR_PTR(err);
860 return file;
861 }
862
863 /*
864 * find another branch who is on the same filesystem of the specified
865 * branch{@btgt}. search until @bbot.
866 */
867 static int is_sb_shared(struct super_block *sb, aufs_bindex_t btgt,
868 aufs_bindex_t bbot)
869 {
870 aufs_bindex_t bindex;
871 struct super_block *tgt_sb = au_sbr_sb(sb, btgt);
872
873 for (bindex = 0; bindex < btgt; bindex++)
874 if (unlikely(tgt_sb == au_sbr_sb(sb, bindex)))
875 return bindex;
876 for (bindex++; bindex <= bbot; bindex++)
877 if (unlikely(tgt_sb == au_sbr_sb(sb, bindex)))
878 return bindex;
879 return -1;
880 }
881
882 /* ---------------------------------------------------------------------- */
883
884 /*
885 * initialize the xinofile for the specified branch @br
886 * at the place/path where @base_file indicates.
887 * test whether another branch is on the same filesystem or not,
888 * if @do_test is true.
889 */
890 int au_xino_br(struct super_block *sb, struct au_branch *br, ino_t h_ino,
891 struct file *base_file, int do_test)
892 {
893 int err;
894 ino_t ino;
895 aufs_bindex_t bbot, bindex;
896 struct au_branch *shared_br, *b;
897 struct file *file;
898 struct super_block *tgt_sb;
899
900 shared_br = NULL;
901 bbot = au_sbbot(sb);
902 if (do_test) {
903 tgt_sb = au_br_sb(br);
904 for (bindex = 0; bindex <= bbot; bindex++) {
905 b = au_sbr(sb, bindex);
906 if (tgt_sb == au_br_sb(b)) {
907 shared_br = b;
908 break;
909 }
910 }
911 }
912
913 if (!shared_br || !shared_br->br_xino.xi_file) {
914 struct au_xino_lock_dir ldir;
915
916 au_xino_lock_dir(sb, base_file, &ldir);
917 /* mnt_want_write() is unnecessary here */
918 file = au_xino_create2(base_file, NULL);
919 au_xino_unlock_dir(&ldir);
920 err = PTR_ERR(file);
921 if (IS_ERR(file))
922 goto out;
923 br->br_xino.xi_file = file;
924 } else {
925 br->br_xino.xi_file = shared_br->br_xino.xi_file;
926 get_file(br->br_xino.xi_file);
927 }
928
929 ino = AUFS_ROOT_INO;
930 err = au_xino_do_write(au_sbi(sb)->si_xwrite, br->br_xino.xi_file,
931 h_ino, ino);
932 if (unlikely(err)) {
933 fput(br->br_xino.xi_file);
934 br->br_xino.xi_file = NULL;
935 }
936
937 out:
938 return err;
939 }
940
941 /* ---------------------------------------------------------------------- */
942
943 /* trucate a xino bitmap file */
944
945 /* todo: slow */
946 static int do_xib_restore(struct super_block *sb, struct file *file, void *page)
947 {
948 int err, bit;
949 ssize_t sz;
950 unsigned long pindex;
951 loff_t pos, pend;
952 struct au_sbinfo *sbinfo;
953 vfs_readf_t func;
954 ino_t *ino;
955 unsigned long *p;
956
957 err = 0;
958 sbinfo = au_sbi(sb);
959 MtxMustLock(&sbinfo->si_xib_mtx);
960 p = sbinfo->si_xib_buf;
961 func = sbinfo->si_xread;
962 pend = vfsub_f_size_read(file);
963 pos = 0;
964 while (pos < pend) {
965 sz = xino_fread(func, file, page, PAGE_SIZE, &pos);
966 err = sz;
967 if (unlikely(sz <= 0))
968 goto out;
969
970 err = 0;
971 for (ino = page; sz > 0; ino++, sz -= sizeof(ino)) {
972 if (unlikely(*ino < AUFS_FIRST_INO))
973 continue;
974
975 xib_calc_bit(*ino, &pindex, &bit);
976 AuDebugOn(page_bits <= bit);
977 err = xib_pindex(sb, pindex);
978 if (!err)
979 set_bit(bit, p);
980 else
981 goto out;
982 }
983 }
984
985 out:
986 return err;
987 }
988
989 static int xib_restore(struct super_block *sb)
990 {
991 int err;
992 aufs_bindex_t bindex, bbot;
993 void *page;
994
995 err = -ENOMEM;
996 page = (void *)__get_free_page(GFP_NOFS);
997 if (unlikely(!page))
998 goto out;
999
1000 err = 0;
1001 bbot = au_sbbot(sb);
1002 for (bindex = 0; !err && bindex <= bbot; bindex++)
1003 if (!bindex || is_sb_shared(sb, bindex, bindex - 1) < 0)
1004 err = do_xib_restore
1005 (sb, au_sbr(sb, bindex)->br_xino.xi_file, page);
1006 else
1007 AuDbg("b%d\n", bindex);
1008 free_page((unsigned long)page);
1009
1010 out:
1011 return err;
1012 }
1013
1014 int au_xib_trunc(struct super_block *sb)
1015 {
1016 int err;
1017 ssize_t sz;
1018 loff_t pos;
1019 struct au_xino_lock_dir ldir;
1020 struct au_sbinfo *sbinfo;
1021 unsigned long *p;
1022 struct file *file;
1023
1024 SiMustWriteLock(sb);
1025
1026 err = 0;
1027 sbinfo = au_sbi(sb);
1028 if (!au_opt_test(sbinfo->si_mntflags, XINO))
1029 goto out;
1030
1031 file = sbinfo->si_xib;
1032 if (vfsub_f_size_read(file) <= PAGE_SIZE)
1033 goto out;
1034
1035 au_xino_lock_dir(sb, file, &ldir);
1036 /* mnt_want_write() is unnecessary here */
1037 file = au_xino_create2(sbinfo->si_xib, NULL);
1038 au_xino_unlock_dir(&ldir);
1039 err = PTR_ERR(file);
1040 if (IS_ERR(file))
1041 goto out;
1042 fput(sbinfo->si_xib);
1043 sbinfo->si_xib = file;
1044
1045 p = sbinfo->si_xib_buf;
1046 memset(p, 0, PAGE_SIZE);
1047 pos = 0;
1048 sz = xino_fwrite(sbinfo->si_xwrite, sbinfo->si_xib, p, PAGE_SIZE, &pos);
1049 if (unlikely(sz != PAGE_SIZE)) {
1050 err = sz;
1051 AuIOErr("err %d\n", err);
1052 if (sz >= 0)
1053 err = -EIO;
1054 goto out;
1055 }
1056
1057 mutex_lock(&sbinfo->si_xib_mtx);
1058 /* mnt_want_write() is unnecessary here */
1059 err = xib_restore(sb);
1060 mutex_unlock(&sbinfo->si_xib_mtx);
1061
1062 out:
1063 return err;
1064 }
1065
1066 /* ---------------------------------------------------------------------- */
1067
1068 /*
1069 * xino mount option handlers
1070 */
1071
1072 /* xino bitmap */
1073 static void xino_clear_xib(struct super_block *sb)
1074 {
1075 struct au_sbinfo *sbinfo;
1076
1077 SiMustWriteLock(sb);
1078
1079 sbinfo = au_sbi(sb);
1080 sbinfo->si_xread = NULL;
1081 sbinfo->si_xwrite = NULL;
1082 if (sbinfo->si_xib)
1083 fput(sbinfo->si_xib);
1084 sbinfo->si_xib = NULL;
1085 if (sbinfo->si_xib_buf)
1086 free_page((unsigned long)sbinfo->si_xib_buf);
1087 sbinfo->si_xib_buf = NULL;
1088 }
1089
1090 static int au_xino_set_xib(struct super_block *sb, struct file *base)
1091 {
1092 int err;
1093 loff_t pos;
1094 struct au_sbinfo *sbinfo;
1095 struct file *file;
1096
1097 SiMustWriteLock(sb);
1098
1099 sbinfo = au_sbi(sb);
1100 file = au_xino_create2(base, sbinfo->si_xib);
1101 err = PTR_ERR(file);
1102 if (IS_ERR(file))
1103 goto out;
1104 if (sbinfo->si_xib)
1105 fput(sbinfo->si_xib);
1106 sbinfo->si_xib = file;
1107 sbinfo->si_xread = vfs_readf(file);
1108 sbinfo->si_xwrite = vfs_writef(file);
1109
1110 err = -ENOMEM;
1111 if (!sbinfo->si_xib_buf)
1112 sbinfo->si_xib_buf = (void *)get_zeroed_page(GFP_NOFS);
1113 if (unlikely(!sbinfo->si_xib_buf))
1114 goto out_unset;
1115
1116 sbinfo->si_xib_last_pindex = 0;
1117 sbinfo->si_xib_next_bit = 0;
1118 if (vfsub_f_size_read(file) < PAGE_SIZE) {
1119 pos = 0;
1120 err = xino_fwrite(sbinfo->si_xwrite, file, sbinfo->si_xib_buf,
1121 PAGE_SIZE, &pos);
1122 if (unlikely(err != PAGE_SIZE))
1123 goto out_free;
1124 }
1125 err = 0;
1126 goto out; /* success */
1127
1128 out_free:
1129 if (sbinfo->si_xib_buf)
1130 free_page((unsigned long)sbinfo->si_xib_buf);
1131 sbinfo->si_xib_buf = NULL;
1132 if (err >= 0)
1133 err = -EIO;
1134 out_unset:
1135 fput(sbinfo->si_xib);
1136 sbinfo->si_xib = NULL;
1137 sbinfo->si_xread = NULL;
1138 sbinfo->si_xwrite = NULL;
1139 out:
1140 return err;
1141 }
1142
1143 /* xino for each branch */
1144 static void xino_clear_br(struct super_block *sb)
1145 {
1146 aufs_bindex_t bindex, bbot;
1147 struct au_branch *br;
1148
1149 bbot = au_sbbot(sb);
1150 for (bindex = 0; bindex <= bbot; bindex++) {
1151 br = au_sbr(sb, bindex);
1152 if (!br || !br->br_xino.xi_file)
1153 continue;
1154
1155 fput(br->br_xino.xi_file);
1156 br->br_xino.xi_file = NULL;
1157 }
1158 }
1159
1160 static int au_xino_set_br(struct super_block *sb, struct file *base)
1161 {
1162 int err;
1163 ino_t ino;
1164 aufs_bindex_t bindex, bbot, bshared;
1165 struct {
1166 struct file *old, *new;
1167 } *fpair, *p;
1168 struct au_branch *br;
1169 struct inode *inode;
1170 vfs_writef_t writef;
1171
1172 SiMustWriteLock(sb);
1173
1174 err = -ENOMEM;
1175 bbot = au_sbbot(sb);
1176 fpair = kcalloc(bbot + 1, sizeof(*fpair), GFP_NOFS);
1177 if (unlikely(!fpair))
1178 goto out;
1179
1180 inode = d_inode(sb->s_root);
1181 ino = AUFS_ROOT_INO;
1182 writef = au_sbi(sb)->si_xwrite;
1183 for (bindex = 0, p = fpair; bindex <= bbot; bindex++, p++) {
1184 bshared = is_sb_shared(sb, bindex, bindex - 1);
1185 if (bshared >= 0) {
1186 /* shared xino */
1187 *p = fpair[bshared];
1188 get_file(p->new);
1189 }
1190
1191 if (!p->new) {
1192 /* new xino */
1193 br = au_sbr(sb, bindex);
1194 p->old = br->br_xino.xi_file;
1195 p->new = au_xino_create2(base, br->br_xino.xi_file);
1196 err = PTR_ERR(p->new);
1197 if (IS_ERR(p->new)) {
1198 p->new = NULL;
1199 goto out_pair;
1200 }
1201 }
1202
1203 err = au_xino_do_write(writef, p->new,
1204 au_h_iptr(inode, bindex)->i_ino, ino);
1205 if (unlikely(err))
1206 goto out_pair;
1207 }
1208
1209 for (bindex = 0, p = fpair; bindex <= bbot; bindex++, p++) {
1210 br = au_sbr(sb, bindex);
1211 if (br->br_xino.xi_file)
1212 fput(br->br_xino.xi_file);
1213 get_file(p->new);
1214 br->br_xino.xi_file = p->new;
1215 }
1216
1217 out_pair:
1218 for (bindex = 0, p = fpair; bindex <= bbot; bindex++, p++)
1219 if (p->new)
1220 fput(p->new);
1221 else
1222 break;
1223 kfree(fpair);
1224 out:
1225 return err;
1226 }
1227
1228 void au_xino_clr(struct super_block *sb)
1229 {
1230 struct au_sbinfo *sbinfo;
1231
1232 au_xigen_clr(sb);
1233 xino_clear_xib(sb);
1234 xino_clear_br(sb);
1235 sbinfo = au_sbi(sb);
1236 /* lvalue, do not call au_mntflags() */
1237 au_opt_clr(sbinfo->si_mntflags, XINO);
1238 }
1239
1240 int au_xino_set(struct super_block *sb, struct au_opt_xino *xino, int remount)
1241 {
1242 int err, skip;
1243 struct dentry *parent, *cur_parent;
1244 struct qstr *dname, *cur_name;
1245 struct file *cur_xino;
1246 struct inode *dir;
1247 struct au_sbinfo *sbinfo;
1248
1249 SiMustWriteLock(sb);
1250
1251 err = 0;
1252 sbinfo = au_sbi(sb);
1253 parent = dget_parent(xino->file->f_path.dentry);
1254 if (remount) {
1255 skip = 0;
1256 dname = &xino->file->f_path.dentry->d_name;
1257 cur_xino = sbinfo->si_xib;
1258 if (cur_xino) {
1259 cur_parent = dget_parent(cur_xino->f_path.dentry);
1260 cur_name = &cur_xino->f_path.dentry->d_name;
1261 skip = (cur_parent == parent
1262 && au_qstreq(dname, cur_name));
1263 dput(cur_parent);
1264 }
1265 if (skip)
1266 goto out;
1267 }
1268
1269 au_opt_set(sbinfo->si_mntflags, XINO);
1270 dir = d_inode(parent);
1271 inode_lock_nested(dir, AuLsc_I_PARENT);
1272 /* mnt_want_write() is unnecessary here */
1273 err = au_xino_set_xib(sb, xino->file);
1274 if (!err)
1275 err = au_xigen_set(sb, xino->file);
1276 if (!err)
1277 err = au_xino_set_br(sb, xino->file);
1278 inode_unlock(dir);
1279 if (!err)
1280 goto out; /* success */
1281
1282 /* reset all */
1283 AuIOErr("failed creating xino(%d).\n", err);
1284 au_xigen_clr(sb);
1285 xino_clear_xib(sb);
1286
1287 out:
1288 dput(parent);
1289 return err;
1290 }
1291
1292 /* ---------------------------------------------------------------------- */
1293
1294 /*
1295 * create a xinofile at the default place/path.
1296 */
1297 struct file *au_xino_def(struct super_block *sb)
1298 {
1299 struct file *file;
1300 char *page, *p;
1301 struct au_branch *br;
1302 struct super_block *h_sb;
1303 struct path path;
1304 aufs_bindex_t bbot, bindex, bwr;
1305
1306 br = NULL;
1307 bbot = au_sbbot(sb);
1308 bwr = -1;
1309 for (bindex = 0; bindex <= bbot; bindex++) {
1310 br = au_sbr(sb, bindex);
1311 if (au_br_writable(br->br_perm)
1312 && !au_test_fs_bad_xino(au_br_sb(br))) {
1313 bwr = bindex;
1314 break;
1315 }
1316 }
1317
1318 if (bwr >= 0) {
1319 file = ERR_PTR(-ENOMEM);
1320 page = (void *)__get_free_page(GFP_NOFS);
1321 if (unlikely(!page))
1322 goto out;
1323 path.mnt = au_br_mnt(br);
1324 path.dentry = au_h_dptr(sb->s_root, bwr);
1325 p = d_path(&path, page, PATH_MAX - sizeof(AUFS_XINO_FNAME));
1326 file = (void *)p;
1327 if (!IS_ERR(p)) {
1328 strcat(p, "/" AUFS_XINO_FNAME);
1329 AuDbg("%s\n", p);
1330 file = au_xino_create(sb, p, /*silent*/0);
1331 if (!IS_ERR(file))
1332 au_xino_brid_set(sb, br->br_id);
1333 }
1334 free_page((unsigned long)page);
1335 } else {
1336 file = au_xino_create(sb, AUFS_XINO_DEFPATH, /*silent*/0);
1337 if (IS_ERR(file))
1338 goto out;
1339 h_sb = file->f_path.dentry->d_sb;
1340 if (unlikely(au_test_fs_bad_xino(h_sb))) {
1341 pr_err("xino doesn't support %s(%s)\n",
1342 AUFS_XINO_DEFPATH, au_sbtype(h_sb));
1343 fput(file);
1344 file = ERR_PTR(-EINVAL);
1345 }
1346 if (!IS_ERR(file))
1347 au_xino_brid_set(sb, -1);
1348 }
1349
1350 out:
1351 return file;
1352 }
1353
1354 /* ---------------------------------------------------------------------- */
1355
1356 int au_xino_path(struct seq_file *seq, struct file *file)
1357 {
1358 int err;
1359
1360 err = au_seq_path(seq, &file->f_path);
1361 if (unlikely(err))
1362 goto out;
1363
1364 #define Deleted "\\040(deleted)"
1365 seq->count -= sizeof(Deleted) - 1;
1366 AuDebugOn(memcmp(seq->buf + seq->count, Deleted,
1367 sizeof(Deleted) - 1));
1368 #undef Deleted
1369
1370 out:
1371 return err;
1372 }
1373
1374 /* ---------------------------------------------------------------------- */
1375
1376 void au_xinondir_leave(struct super_block *sb, aufs_bindex_t bindex,
1377 ino_t h_ino, int idx)
1378 {
1379 struct au_xino_file *xino;
1380
1381 AuDebugOn(!au_opt_test(au_mntflags(sb), XINO));
1382 xino = &au_sbr(sb, bindex)->br_xino;
1383 AuDebugOn(idx < 0 || xino->xi_nondir.total <= idx);
1384
1385 spin_lock(&xino->xi_nondir.spin);
1386 AuDebugOn(xino->xi_nondir.array[idx] != h_ino);
1387 xino->xi_nondir.array[idx] = 0;
1388 spin_unlock(&xino->xi_nondir.spin);
1389 wake_up_all(&xino->xi_nondir.wqh);
1390 }
1391
1392 static int au_xinondir_find(struct au_xino_file *xino, ino_t h_ino)
1393 {
1394 int found, total, i;
1395
1396 found = -1;
1397 total = xino->xi_nondir.total;
1398 for (i = 0; i < total; i++) {
1399 if (xino->xi_nondir.array[i] != h_ino)
1400 continue;
1401 found = i;
1402 break;
1403 }
1404
1405 return found;
1406 }
1407
1408 static int au_xinondir_expand(struct au_xino_file *xino)
1409 {
1410 int err, sz;
1411 ino_t *p;
1412
1413 BUILD_BUG_ON(KMALLOC_MAX_SIZE > INT_MAX);
1414
1415 err = -ENOMEM;
1416 sz = xino->xi_nondir.total * sizeof(ino_t);
1417 if (unlikely(sz > KMALLOC_MAX_SIZE / 2))
1418 goto out;
1419 p = au_kzrealloc(xino->xi_nondir.array, sz, sz << 1, GFP_ATOMIC,
1420 /*may_shrink*/0);
1421 if (p) {
1422 xino->xi_nondir.array = p;
1423 xino->xi_nondir.total <<= 1;
1424 AuDbg("xi_nondir.total %d\n", xino->xi_nondir.total);
1425 err = 0;
1426 }
1427
1428 out:
1429 return err;
1430 }
1431
1432 int au_xinondir_enter(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
1433 int *idx)
1434 {
1435 int err, found, empty;
1436 struct au_xino_file *xino;
1437
1438 err = 0;
1439 *idx = -1;
1440 if (!au_opt_test(au_mntflags(sb), XINO))
1441 goto out; /* no xino */
1442
1443 xino = &au_sbr(sb, bindex)->br_xino;
1444
1445 again:
1446 spin_lock(&xino->xi_nondir.spin);
1447 found = au_xinondir_find(xino, h_ino);
1448 if (found == -1) {
1449 empty = au_xinondir_find(xino, /*h_ino*/0);
1450 if (empty == -1) {
1451 empty = xino->xi_nondir.total;
1452 err = au_xinondir_expand(xino);
1453 if (unlikely(err))
1454 goto out_unlock;
1455 }
1456 xino->xi_nondir.array[empty] = h_ino;
1457 *idx = empty;
1458 } else {
1459 spin_unlock(&xino->xi_nondir.spin);
1460 wait_event(xino->xi_nondir.wqh,
1461 xino->xi_nondir.array[found] != h_ino);
1462 goto again;
1463 }
1464
1465 out_unlock:
1466 spin_unlock(&xino->xi_nondir.spin);
1467 out:
1468 return err;
1469 }