2
* Copyright (C) 2005-2009 Junjiro R. Okajima
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.
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.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
* external inode number translation table and bitmap
23
#include <linux/file.h>
24
#include <linux/seq_file.h>
25
#include <linux/uaccess.h>
28
ssize_t xino_fread(au_readf_t func, struct file *file, void *buf, size_t size,
37
/* todo: signal_pending? */
38
err = func(file, (char __user *)buf, size, pos);
39
} while (err == -EAGAIN || err == -EINTR);
42
#if 0 /* reserved for future use */
44
fsnotify_access(file->f_dentry);
50
/* ---------------------------------------------------------------------- */
52
static ssize_t do_xino_fwrite(au_writef_t func, struct file *file, void *buf,
53
size_t size, loff_t *pos)
62
/* todo: signal_pending? */
63
err = func(file, (const char __user *)buf, size, pos);
64
} while (err == -EAGAIN || err == -EINTR);
68
#if 0 /* reserved for future use */
70
fsnotify_modify(file->f_dentry);
76
struct do_xino_fwrite_args {
85
static void call_do_xino_fwrite(void *args)
87
struct do_xino_fwrite_args *a = args;
88
*a->errp = do_xino_fwrite(a->func, a->file, a->buf, a->size, a->pos);
91
ssize_t xino_fwrite(au_writef_t func, struct file *file, void *buf, size_t size,
96
/* todo: signal block and no wkq? */
97
/* todo: new credential scheme */
99
* it breaks RLIMIT_FSIZE and normal user's limit,
100
* users should care about quota and real 'filesystem full.'
102
if (!au_test_wkq(current)) {
104
struct do_xino_fwrite_args args = {
113
wkq_err = au_wkq_wait(call_do_xino_fwrite, &args);
114
if (unlikely(wkq_err))
117
err = do_xino_fwrite(func, file, buf, size, pos);
122
/* ---------------------------------------------------------------------- */
125
* create a new xinofile at the same place/path as @base_file.
127
struct file *au_xino_create2(struct file *base_file, struct file *copy_src)
130
struct dentry *base, *dentry, *parent;
135
base = base_file->f_dentry;
136
parent = base->d_parent; /* dir inode is locked */
137
dir = parent->d_inode;
140
file = ERR_PTR(-EINVAL);
141
name = &base->d_name;
142
dentry = vfsub_lookup_one_len(name->name, parent, name->len);
143
if (IS_ERR(dentry)) {
144
file = (void *)dentry;
145
AuErr("%.*s lookup err %ld\n", AuLNPair(name), PTR_ERR(dentry));
149
/* no need to mnt_want_write() since we call dentry_open() later */
150
err = vfs_create(dir, dentry, S_IRUGO | S_IWUGO, NULL);
153
AuErr("%.*s create err %d\n", AuLNPair(name), err);
157
file = dentry_open(dget(dentry), mntget(base_file->f_vfsmnt),
158
O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE,
161
AuErr("%.*s open err %ld\n", AuLNPair(name), PTR_ERR(file));
165
err = vfsub_unlink(dir, &file->f_path, /*force*/0);
167
AuErr("%.*s unlink err %d\n", AuLNPair(name), err);
172
/* no one can touch copy_src xino */
173
err = au_copy_file(file, copy_src,
174
i_size_read(copy_src->f_dentry->d_inode));
176
AuErr("%.*s copy err %d\n", AuLNPair(name), err);
180
goto out_dput; /* success */
191
struct au_xino_lock_dir {
192
struct au_hinode *hdir;
193
struct dentry *parent;
197
static void au_xino_lock_dir(struct super_block *sb, struct file *xino,
198
struct au_xino_lock_dir *ldir)
200
aufs_bindex_t brid, bindex;
204
brid = au_xino_brid(sb);
206
bindex = au_br_index(sb, brid);
208
ldir->hdir = au_hi(sb->s_root->d_inode, bindex);
209
au_hin_imtx_lock_nested(ldir->hdir, AuLsc_I_PARENT);
211
ldir->parent = dget_parent(xino->f_dentry);
212
ldir->mtx = &ldir->parent->d_inode->i_mutex;
213
mutex_lock_nested(ldir->mtx, AuLsc_I_PARENT);
217
static void au_xino_unlock_dir(struct au_xino_lock_dir *ldir)
220
au_hin_imtx_unlock(ldir->hdir);
222
mutex_unlock(ldir->mtx);
227
/* ---------------------------------------------------------------------- */
229
/* trucate xino files asynchronously */
231
int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex)
234
aufs_bindex_t bi, bend;
235
struct au_branch *br;
236
struct file *new_xino, *file;
237
struct super_block *h_sb;
238
struct au_xino_lock_dir ldir;
242
if (unlikely(bindex < 0 || bend < bindex))
244
br = au_sbr(sb, bindex);
245
file = br->br_xino.xi_file;
249
au_xino_lock_dir(sb, file, &ldir);
250
/* mnt_want_write() is unnecessary here */
251
new_xino = au_xino_create2(file, file);
252
au_xino_unlock_dir(&ldir);
253
err = PTR_ERR(new_xino);
254
if (IS_ERR(new_xino))
258
br->br_xino.xi_file = new_xino;
260
h_sb = br->br_mnt->mnt_sb;
261
for (bi = 0; bi <= bend; bi++) {
262
if (unlikely(bi == bindex))
265
if (br->br_mnt->mnt_sb != h_sb)
268
fput(br->br_xino.xi_file);
269
br->br_xino.xi_file = new_xino;
277
struct xino_do_trunc_args {
278
struct super_block *sb;
279
struct au_branch *br;
282
static void xino_do_trunc(void *_args)
284
struct xino_do_trunc_args *args = _args;
285
struct super_block *sb;
286
struct au_branch *br;
289
aufs_bindex_t bindex;
293
dir = sb->s_root->d_inode;
296
si_noflush_write_lock(sb);
297
ii_read_lock_parent(dir);
298
bindex = au_br_index(sb, br->br_id);
299
err = au_xino_trunc(sb, bindex);
301
&& br->br_xino.xi_file->f_dentry->d_inode->i_blocks
302
>= br->br_xino_upper)
303
br->br_xino_upper += AUFS_XINO_TRUNC_STEP;
307
AuWarn("err b%d, (%d)\n", bindex, err);
308
atomic_dec(&br->br_xino_running);
309
atomic_dec(&br->br_count);
310
au_nwt_done(&au_sbi(sb)->si_nowait);
315
static void xino_try_trunc(struct super_block *sb, struct au_branch *br)
317
struct xino_do_trunc_args *args;
320
if (br->br_xino.xi_file->f_dentry->d_inode->i_blocks
324
if (atomic_inc_return(&br->br_xino_running) > 1)
327
/* lock and kfree() will be called in trunc_xino() */
328
args = kmalloc(sizeof(*args), GFP_NOFS);
329
if (unlikely(!args)) {
330
AuErr1("no memory\n");
334
atomic_inc_return(&br->br_count);
337
wkq_err = au_wkq_nowait(xino_do_trunc, args, sb);
339
return; /* success */
341
AuErr("wkq %d\n", wkq_err);
342
atomic_dec_return(&br->br_count);
347
atomic_dec_return(&br->br_xino_running);
350
/* ---------------------------------------------------------------------- */
352
static int au_xino_do_write(au_writef_t write, struct file *file,
353
ino_t h_ino, ino_t ino)
359
if (unlikely(au_loff_max / sizeof(ino) - 1 < pos)) {
360
AuIOErr1("too large hi%lu\n", (unsigned long)h_ino);
364
sz = xino_fwrite(write, file, &ino, sizeof(ino), &pos);
365
if (sz == sizeof(ino))
366
return 0; /* success */
368
AuIOErr("write failed (%zd)\n", sz);
373
* write @ino to the xinofile for the specified branch{@sb, @bindex}
374
* at the position of @h_ino.
375
* even if @ino is zero, it is written to the xinofile and means no entry.
376
* if the size of the xino file on a specific filesystem exceeds the watermark,
379
int au_xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
383
unsigned int mnt_flags;
384
struct au_branch *br;
386
BUILD_BUG_ON(sizeof(long long) != sizeof(au_loff_max)
387
|| ((loff_t)-1) > 0);
390
mnt_flags = au_mntflags(sb);
391
if (!au_opt_test(mnt_flags, XINO))
394
br = au_sbr(sb, bindex);
395
err = au_xino_do_write(au_sbi(sb)->si_xwrite, br->br_xino.xi_file,
398
if (au_opt_test(mnt_flags, TRUNC_XINO)
399
&& au_test_fs_trunc_xino(br->br_mnt->mnt_sb))
400
xino_try_trunc(sb, br);
401
return 0; /* success */
404
AuIOErr("write failed (%d)\n", err);
408
/* ---------------------------------------------------------------------- */
410
/* aufs inode number bitmap */
412
static const int page_bits = (int)PAGE_SIZE * BITS_PER_BYTE;
413
static ino_t xib_calc_ino(unsigned long pindex, int bit)
417
AuDebugOn(bit < 0 || page_bits <= bit);
418
ino = AUFS_FIRST_INO + pindex * page_bits + bit;
422
static void xib_calc_bit(ino_t ino, unsigned long *pindex, int *bit)
424
AuDebugOn(ino < AUFS_FIRST_INO);
425
ino -= AUFS_FIRST_INO;
426
*pindex = ino / page_bits;
427
*bit = ino % page_bits;
430
static int xib_pindex(struct super_block *sb, unsigned long pindex)
435
struct au_sbinfo *sbinfo;
440
MtxMustLock(&sbinfo->si_xib_mtx);
441
AuDebugOn(pindex > ULONG_MAX / PAGE_SIZE
442
|| !au_opt_test(sbinfo->si_mntflags, XINO));
444
if (pindex == sbinfo->si_xib_last_pindex)
447
xib = sbinfo->si_xib;
448
p = sbinfo->si_xib_buf;
449
pos = sbinfo->si_xib_last_pindex;
451
sz = xino_fwrite(sbinfo->si_xwrite, xib, p, PAGE_SIZE, &pos);
452
if (unlikely(sz != PAGE_SIZE))
457
if (i_size_read(xib->f_dentry->d_inode) >= pos + PAGE_SIZE)
458
sz = xino_fread(sbinfo->si_xread, xib, p, PAGE_SIZE, &pos);
460
memset(p, 0, PAGE_SIZE);
461
sz = xino_fwrite(sbinfo->si_xwrite, xib, p, PAGE_SIZE, &pos);
463
if (sz == PAGE_SIZE) {
464
sbinfo->si_xib_last_pindex = pindex;
465
return 0; /* success */
469
AuIOErr1("write failed (%zd)\n", sz);
476
/* ---------------------------------------------------------------------- */
478
int au_xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
482
unsigned long pindex;
483
struct au_sbinfo *sbinfo;
485
if (!au_opt_test(au_mntflags(sb), XINO))
491
xib_calc_bit(ino, &pindex, &bit);
492
AuDebugOn(page_bits <= bit);
493
mutex_lock(&sbinfo->si_xib_mtx);
494
err = xib_pindex(sb, pindex);
496
clear_bit(bit, sbinfo->si_xib_buf);
497
sbinfo->si_xib_next_bit = bit;
499
mutex_unlock(&sbinfo->si_xib_mtx);
503
err = au_xino_write(sb, bindex, h_ino, 0);
507
/* get an unused inode number from bitmap */
508
ino_t au_xino_new_ino(struct super_block *sb)
511
unsigned long *p, pindex, ul, pend;
512
struct au_sbinfo *sbinfo;
516
if (!au_opt_test(au_mntflags(sb), XINO))
517
return iunique(sb, AUFS_FIRST_INO);
520
mutex_lock(&sbinfo->si_xib_mtx);
521
p = sbinfo->si_xib_buf;
522
free_bit = sbinfo->si_xib_next_bit;
523
if (free_bit < page_bits && !test_bit(free_bit, p))
524
goto out; /* success */
525
free_bit = find_first_zero_bit(p, page_bits);
526
if (free_bit < page_bits)
527
goto out; /* success */
529
pindex = sbinfo->si_xib_last_pindex;
530
for (ul = pindex - 1; ul < ULONG_MAX; ul--) {
531
err = xib_pindex(sb, ul);
534
free_bit = find_first_zero_bit(p, page_bits);
535
if (free_bit < page_bits)
536
goto out; /* success */
539
file = sbinfo->si_xib;
540
pend = i_size_read(file->f_dentry->d_inode) / PAGE_SIZE;
541
for (ul = pindex + 1; ul <= pend; ul++) {
542
err = xib_pindex(sb, ul);
545
free_bit = find_first_zero_bit(p, page_bits);
546
if (free_bit < page_bits)
547
goto out; /* success */
552
set_bit(free_bit, p);
553
sbinfo->si_xib_next_bit++;
554
pindex = sbinfo->si_xib_last_pindex;
555
mutex_unlock(&sbinfo->si_xib_mtx);
556
ino = xib_calc_ino(pindex, free_bit);
557
AuDbg("i%lu\n", (unsigned long)ino);
560
mutex_unlock(&sbinfo->si_xib_mtx);
566
* read @ino from xinofile for the specified branch{@sb, @bindex}
567
* at the position of @h_ino.
568
* if @ino does not exist and @do_new is true, get new one.
570
int au_xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
577
struct au_sbinfo *sbinfo;
580
if (!au_opt_test(au_mntflags(sb), XINO))
581
return 0; /* no xino */
586
if (unlikely(au_loff_max / sizeof(*ino) - 1 < pos)) {
587
AuIOErr1("too large hi%lu\n", (unsigned long)h_ino);
592
file = au_sbr(sb, bindex)->br_xino.xi_file;
593
if (i_size_read(file->f_dentry->d_inode) < pos + sizeof(*ino))
594
return 0; /* no ino */
596
sz = xino_fread(sbinfo->si_xread, file, ino, sizeof(*ino), &pos);
597
if (sz == sizeof(*ino))
598
return 0; /* success */
601
if (unlikely(sz >= 0)) {
603
AuIOErr("xino read error (%zd)\n", sz);
609
/* ---------------------------------------------------------------------- */
611
/* create and set a new xino file */
613
struct file *au_xino_create(struct super_block *sb, char *fname, int silent)
616
struct dentry *h_parent, *d;
621
* at mount-time, and the xino file is the default path,
622
* hinotify is disabled so we have no inotify events to ignore.
623
* when a user specified the xino, we cannot get au_hdir to be ignored.
625
file = vfsub_filp_open(fname, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE,
629
AuErr("open %s(%ld)\n", fname, PTR_ERR(file));
633
/* keep file count */
634
h_parent = dget_parent(file->f_dentry);
635
h_dir = h_parent->d_inode;
636
mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
637
/* mnt_want_write() is unnecessary here */
638
err = vfsub_unlink(h_dir, &file->f_path, /*force*/0);
639
mutex_unlock(&h_dir->i_mutex);
643
AuErr("unlink %s(%d)\n", fname, err);
649
if (unlikely(sb == d->d_sb)) {
651
AuErr("%s must be outside\n", fname);
654
if (unlikely(au_test_fs_bad_xino(d->d_sb))) {
656
AuErr("xino doesn't support %s(%s)\n",
657
fname, au_sbtype(d->d_sb));
660
return file; /* success */
669
* find another branch who is on the same filesystem of the specified
670
* branch{@btgt}. search until @bend.
672
static int is_sb_shared(struct super_block *sb, aufs_bindex_t btgt,
675
aufs_bindex_t bindex;
676
struct super_block *tgt_sb = au_sbr_sb(sb, btgt);
678
for (bindex = 0; bindex < btgt; bindex++)
679
if (unlikely(tgt_sb == au_sbr_sb(sb, bindex)))
681
for (bindex++; bindex <= bend; bindex++)
682
if (unlikely(tgt_sb == au_sbr_sb(sb, bindex)))
687
/* ---------------------------------------------------------------------- */
690
* initialize the xinofile for the specified branch @br
691
* at the place/path where @base_file indicates.
692
* test whether another branch is on the same filesystem or not,
693
* if @do_test is true.
695
int au_xino_br(struct super_block *sb, struct au_branch *br, ino_t h_ino,
696
struct file *base_file, int do_test)
700
aufs_bindex_t bend, bindex;
701
struct au_branch *shared_br, *b;
703
struct super_block *tgt_sb;
708
tgt_sb = br->br_mnt->mnt_sb;
709
for (bindex = 0; bindex <= bend; bindex++) {
710
b = au_sbr(sb, bindex);
711
if (tgt_sb == b->br_mnt->mnt_sb) {
718
if (!shared_br || !shared_br->br_xino.xi_file) {
719
struct au_xino_lock_dir ldir;
721
au_xino_lock_dir(sb, base_file, &ldir);
722
/* mnt_want_write() is unnecessary here */
723
file = au_xino_create2(base_file, NULL);
724
au_xino_unlock_dir(&ldir);
728
br->br_xino.xi_file = file;
730
br->br_xino.xi_file = shared_br->br_xino.xi_file;
731
get_file(br->br_xino.xi_file);
735
err = au_xino_do_write(au_sbi(sb)->si_xwrite, br->br_xino.xi_file,
738
return 0; /* success */
745
/* ---------------------------------------------------------------------- */
747
/* trucate a xino bitmap file */
750
static int do_xib_restore(struct super_block *sb, struct file *file, void *page)
754
unsigned long pindex;
756
struct au_sbinfo *sbinfo;
763
MtxMustLock(&sbinfo->si_xib_mtx);
764
p = sbinfo->si_xib_buf;
765
func = sbinfo->si_xread;
766
pend = i_size_read(file->f_dentry->d_inode);
769
sz = xino_fread(func, file, page, PAGE_SIZE, &pos);
771
if (unlikely(sz <= 0))
775
for (ino = page; sz > 0; ino++, sz -= sizeof(ino)) {
776
if (unlikely(*ino < AUFS_FIRST_INO))
779
xib_calc_bit(*ino, &pindex, &bit);
780
AuDebugOn(page_bits <= bit);
781
err = xib_pindex(sb, pindex);
793
static int xib_restore(struct super_block *sb)
796
aufs_bindex_t bindex, bend;
800
page = (void *)__get_free_page(GFP_NOFS);
806
for (bindex = 0; !err && bindex <= bend; bindex++)
807
if (!bindex || is_sb_shared(sb, bindex, bindex - 1) < 0)
809
(sb, au_sbr(sb, bindex)->br_xino.xi_file, page);
811
AuDbg("b%d\n", bindex);
812
free_page((unsigned long)page);
818
int au_xib_trunc(struct super_block *sb)
823
struct au_xino_lock_dir ldir;
824
struct au_sbinfo *sbinfo;
832
if (!au_opt_test(sbinfo->si_mntflags, XINO))
835
file = sbinfo->si_xib;
836
if (i_size_read(file->f_dentry->d_inode) <= PAGE_SIZE)
839
au_xino_lock_dir(sb, file, &ldir);
840
/* mnt_want_write() is unnecessary here */
841
file = au_xino_create2(sbinfo->si_xib, NULL);
842
au_xino_unlock_dir(&ldir);
846
fput(sbinfo->si_xib);
847
sbinfo->si_xib = file;
849
p = sbinfo->si_xib_buf;
850
memset(p, 0, PAGE_SIZE);
852
sz = xino_fwrite(sbinfo->si_xwrite, sbinfo->si_xib, p, PAGE_SIZE, &pos);
853
if (unlikely(sz != PAGE_SIZE)) {
855
AuIOErr("err %d\n", err);
861
mutex_lock(&sbinfo->si_xib_mtx);
862
/* mnt_want_write() is unnecessary here */
863
err = xib_restore(sb);
864
mutex_unlock(&sbinfo->si_xib_mtx);
870
/* ---------------------------------------------------------------------- */
873
* xino mount option handlers
875
static au_readf_t find_readf(struct file *h_file)
877
const struct file_operations *fop = h_file->f_op;
885
return ERR_PTR(-ENOSYS);
888
static au_writef_t find_writef(struct file *h_file)
890
const struct file_operations *fop = h_file->f_op;
896
return do_sync_write;
898
return ERR_PTR(-ENOSYS);
902
static void xino_clear_xib(struct super_block *sb)
904
struct au_sbinfo *sbinfo;
909
sbinfo->si_xread = NULL;
910
sbinfo->si_xwrite = NULL;
912
fput(sbinfo->si_xib);
913
sbinfo->si_xib = NULL;
914
free_page((unsigned long)sbinfo->si_xib_buf);
915
sbinfo->si_xib_buf = NULL;
918
static int au_xino_set_xib(struct super_block *sb, struct file *base)
922
struct au_sbinfo *sbinfo;
928
file = au_xino_create2(base, sbinfo->si_xib);
933
fput(sbinfo->si_xib);
934
sbinfo->si_xib = file;
935
sbinfo->si_xread = find_readf(file);
936
sbinfo->si_xwrite = find_writef(file);
939
if (!sbinfo->si_xib_buf)
940
sbinfo->si_xib_buf = (void *)get_zeroed_page(GFP_NOFS);
941
if (unlikely(!sbinfo->si_xib_buf))
944
sbinfo->si_xib_last_pindex = 0;
945
sbinfo->si_xib_next_bit = 0;
946
if (i_size_read(file->f_dentry->d_inode) < PAGE_SIZE) {
948
err = xino_fwrite(sbinfo->si_xwrite, file, sbinfo->si_xib_buf,
950
if (unlikely(err != PAGE_SIZE))
954
goto out; /* success */
957
free_page((unsigned long)sbinfo->si_xib_buf);
958
sbinfo->si_xib_buf = NULL;
962
fput(sbinfo->si_xib);
963
sbinfo->si_xib = NULL;
964
sbinfo->si_xread = NULL;
965
sbinfo->si_xwrite = NULL;
970
/* xino for each branch */
971
static void xino_clear_br(struct super_block *sb)
973
aufs_bindex_t bindex, bend;
974
struct au_branch *br;
977
for (bindex = 0; bindex <= bend; bindex++) {
978
br = au_sbr(sb, bindex);
979
if (!br || !br->br_xino.xi_file)
982
fput(br->br_xino.xi_file);
983
br->br_xino.xi_file = NULL;
987
static int au_xino_set_br(struct super_block *sb, struct file *base)
991
aufs_bindex_t bindex, bend, bshared;
993
struct file *old, *new;
995
struct au_branch *br;
1002
bend = au_sbend(sb);
1003
fpair = kcalloc(bend + 1, sizeof(*fpair), GFP_NOFS);
1004
if (unlikely(!fpair))
1007
inode = sb->s_root->d_inode;
1008
ino = AUFS_ROOT_INO;
1009
writef = au_sbi(sb)->si_xwrite;
1010
for (bindex = 0, p = fpair; bindex <= bend; bindex++, p++) {
1011
br = au_sbr(sb, bindex);
1012
bshared = is_sb_shared(sb, bindex, bindex - 1);
1015
*p = fpair[bshared];
1021
p->old = br->br_xino.xi_file;
1022
p->new = au_xino_create2(base, br->br_xino.xi_file);
1023
err = PTR_ERR(p->new);
1024
if (IS_ERR(p->new)) {
1030
err = au_xino_do_write(writef, p->new,
1031
au_h_iptr(inode, bindex)->i_ino, ino);
1036
for (bindex = 0, p = fpair; bindex <= bend; bindex++, p++) {
1037
br = au_sbr(sb, bindex);
1038
if (br->br_xino.xi_file)
1039
fput(br->br_xino.xi_file);
1041
br->br_xino.xi_file = p->new;
1045
for (bindex = 0, p = fpair; bindex <= bend; bindex++, p++)
1055
void au_xino_clr(struct super_block *sb)
1057
struct au_sbinfo *sbinfo;
1062
sbinfo = au_sbi(sb);
1063
/* lvalue, do not call au_mntflags() */
1064
au_opt_clr(sbinfo->si_mntflags, XINO);
1067
int au_xino_set(struct super_block *sb, struct au_opt_xino *xino, int remount)
1070
struct dentry *parent, *cur_parent;
1071
struct qstr *dname, *cur_name;
1072
struct file *cur_xino;
1074
struct au_sbinfo *sbinfo;
1076
SiMustWriteLock(sb);
1079
sbinfo = au_sbi(sb);
1080
parent = dget_parent(xino->file->f_dentry);
1083
dname = &xino->file->f_dentry->d_name;
1084
cur_xino = sbinfo->si_xib;
1086
cur_parent = dget_parent(cur_xino->f_dentry);
1087
cur_name = &cur_xino->f_dentry->d_name;
1088
skip = (cur_parent == parent
1089
&& dname->len == cur_name->len
1090
&& !memcmp(dname->name, cur_name->name,
1098
au_opt_set(sbinfo->si_mntflags, XINO);
1099
dir = parent->d_inode;
1100
mutex_lock_nested(&dir->i_mutex, AuLsc_I_PARENT);
1101
/* mnt_want_write() is unnecessary here */
1102
err = au_xino_set_xib(sb, xino->file);
1104
err = au_xigen_set(sb, xino->file);
1106
err = au_xino_set_br(sb, xino->file);
1107
mutex_unlock(&dir->i_mutex);
1109
goto out; /* success */
1112
AuIOErr("failed creating xino(%d).\n", err);
1119
/* ---------------------------------------------------------------------- */
1122
* create a xinofile at the default place/path.
1124
struct file *au_xino_def(struct super_block *sb)
1128
struct au_branch *br;
1129
struct super_block *h_sb;
1131
aufs_bindex_t bend, bindex, bwr;
1134
bend = au_sbend(sb);
1136
for (bindex = 0; bindex <= bend; bindex++) {
1137
br = au_sbr(sb, bindex);
1138
if (au_br_writable(br->br_perm)
1139
&& !au_test_fs_bad_xino(br->br_mnt->mnt_sb)) {
1146
file = ERR_PTR(-ENOMEM);
1148
if (unlikely(!page))
1150
path.mnt = br->br_mnt;
1151
path.dentry = au_h_dptr(sb->s_root, bwr);
1152
p = d_path(&path, page, PATH_MAX - sizeof(AUFS_XINO_FNAME));
1155
strcat(p, "/" AUFS_XINO_FNAME);
1157
file = au_xino_create(sb, p, /*silent*/0);
1159
au_xino_brid_set(sb, br->br_id);
1163
file = au_xino_create(sb, AUFS_XINO_DEFPATH, /*silent*/0);
1166
h_sb = file->f_dentry->d_sb;
1167
if (unlikely(au_test_fs_bad_xino(h_sb))) {
1168
AuErr("xino doesn't support %s(%s)\n",
1169
AUFS_XINO_DEFPATH, au_sbtype(h_sb));
1171
file = ERR_PTR(-EINVAL);
1174
au_xino_brid_set(sb, -1);
1181
/* ---------------------------------------------------------------------- */
1183
int au_xino_path(struct seq_file *seq, struct file *file)
1187
err = au_seq_path(seq, &file->f_path);
1188
if (unlikely(err < 0))
1192
#define Deleted "\\040(deleted)"
1193
seq->count -= sizeof(Deleted) - 1;
1194
AuDebugOn(memcmp(seq->buf + seq->count, Deleted,
1195
sizeof(Deleted) - 1));