~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs25/dentry.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-08-21 14:58:54 UTC
  • mfrom: (1.1.8 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080821145854-4b49x09r4zmvlk5o
Tags: 0+20080719-4
01_vserver_apparmor.dpatch: [UPDATE] Disable vserver patches on kernel 
2.6.26, because they are not needed anymore. (Closes: #495921)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
/*
20
20
 * lookup and dentry operations
21
21
 *
22
 
 * $Id: dentry.c,v 1.8 2008/06/02 02:38:21 sfjro Exp $
 
22
 * $Id: dentry.c,v 1.10 2008/07/07 01:09:22 sfjro Exp $
23
23
 */
24
24
 
25
25
#include "aufs.h"
96
96
                            struct au_do_lookup_args *args)
97
97
{
98
98
        struct dentry *h_dentry;
99
 
        int wh_found, wh_able, opq, err;
 
99
        int err, wh_found, opq;
 
100
        unsigned char wh_able;
100
101
        struct inode *h_dir, *h_inode, *inode;
101
102
        struct qstr *name;
102
103
        struct super_block *sb;
125
126
                au_fset_ndx(ndx.flags, DIRPERM1);
126
127
        LKTRTrace("nfsmnt %p\n", ndx.nfsmnt);
127
128
        ndx.br = au_sbr(sb, bindex);
128
 
        wh_able = au_br_whable(ndx.br->br_perm);
 
129
        wh_able = !!au_br_whable(ndx.br->br_perm);
129
130
        name = &dentry->d_name;
130
131
        if (unlikely(wh_able))
131
132
                wh_found = au_test_robr_wh(name, h_parent, wh_name,
208
209
int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type,
209
210
                   struct nameidata *nd)
210
211
{
211
 
        int npositive, err, isdir;
 
212
        int npositive, err;
212
213
        struct dentry *parent;
213
214
        aufs_bindex_t bindex, btail, bdiropq;
 
215
        unsigned char isdir;
214
216
        const struct qstr *name = &dentry->d_name;
215
217
        struct qstr whname;
216
218
        struct super_block *sb;
238
240
        sb = dentry->d_sb;
239
241
        mnt_flags = au_mntflags(sb);
240
242
        inode = dentry->d_inode;
241
 
        isdir = (inode && S_ISDIR(inode->i_mode));
 
243
        isdir = !!(inode && S_ISDIR(inode->i_mode));
242
244
        args.flags = 0;
243
245
        if (unlikely(au_test_dlgt(mnt_flags)))
244
246
                au_fset_lkup(args.flags, DLGT);
430
432
        new_sz = sizeof(*dinfo->di_hdentry) * (au_sbend(sb) + 1);
431
433
        dinfo = au_di(dentry);
432
434
        p = au_kzrealloc(dinfo->di_hdentry, sizeof(*p) * (dinfo->di_bend + 1),
433
 
                         new_sz, GFP_KERNEL);
 
435
                         new_sz, GFP_NOFS);
434
436
        if (unlikely(!p))
435
437
                goto out;
436
438
        dinfo->di_hdentry = p;
535
537
}
536
538
 
537
539
/* #define TestingFuse */
538
 
static noinline_for_stack int
539
 
au_do_h_d_reval(struct dentry *dentry, aufs_bindex_t bindex,
540
 
                struct nameidata *nd, struct dentry *h_dentry)
 
540
static noinline_for_stack
 
541
int au_do_h_d_reval(struct dentry *dentry, aufs_bindex_t bindex,
 
542
                    struct nameidata *nd, struct dentry *h_dentry)
541
543
{
542
544
        int err, valid, e;
543
545
        int (*reval)(struct dentry *, struct nameidata *);
596
598
        return err;
597
599
}
598
600
 
599
 
static noinline_for_stack int
600
 
h_d_revalidate(struct dentry *dentry, struct inode *inode,
601
 
               struct nameidata *nd, int do_udba)
 
601
static noinline_for_stack
 
602
int h_d_revalidate(struct dentry *dentry, struct inode *inode,
 
603
                   struct nameidata *nd, int do_udba)
602
604
{
603
 
        int err, plus, locked, unhashed, is_root, h_plus;
 
605
        int err;
604
606
        aufs_bindex_t bindex, btail, bstart, ibs, ibe;
 
607
        unsigned char plus, locked, unhashed, is_root, h_plus;
605
608
        struct super_block *sb;
606
609
        struct inode *first, *h_inode, *h_cached_inode;
607
610
        umode_t mode, h_mode;
618
621
        first = NULL;
619
622
        ibs = -1;
620
623
        ibe = -1;
621
 
        unhashed = d_unhashed(dentry);
622
 
        is_root = IS_ROOT(dentry);
 
624
        unhashed = !!d_unhashed(dentry);
 
625
        is_root = !!IS_ROOT(dentry);
623
626
        name = &dentry->d_name;
624
627
 
625
628
        /*
641
644
        btail = bstart;
642
645
        if (inode && S_ISDIR(inode->i_mode))
643
646
                btail = au_dbtaildir(dentry);
644
 
        locked = au_lock_nd(dentry, nd);
 
647
        locked = !!au_lock_nd(dentry, nd);
645
648
        for (bindex = bstart; bindex <= btail; bindex++) {
646
649
                h_dentry = au_h_dptr(dentry, bindex);
647
650
                if (!h_dentry)
656
659
 
657
660
                if (unlikely(do_udba
658
661
                             && !is_root
659
 
                             && (unhashed != d_unhashed(h_dentry)
 
662
                             && (unhashed != !!d_unhashed(h_dentry)
660
663
                                 || name->len != h_dentry->d_name.len
661
664
                                 || memcmp(name->name, h_dentry->d_name.name,
662
665
                                           name->len)
672
675
                        /* do not goto err, to keep the errno */
673
676
                        break;
674
677
 
 
678
                /* todo: plink too? */
675
679
                if (unlikely(!do_udba))
676
680
                        continue;
677
681
 
690
694
                if (inode && ibs <= bindex && bindex <= ibe)
691
695
                        h_cached_inode = au_h_iptr(inode, bindex);
692
696
 
693
 
                LKTRTrace("{%d, 0%o, %d}, h{%d, 0%o, %d}\n",
694
 
                          plus, mode, !!h_cached_inode,
695
 
                          h_plus, h_mode, !!h_inode);
 
697
                LKTRTrace("{%d, 0%o, %p}, h{%d, 0%o, %p}\n",
 
698
                          plus, mode, h_cached_inode,
 
699
                          h_plus, h_mode, h_inode);
696
700
                if (unlikely(plus != h_plus
697
701
                             || mode != h_mode
698
702
                             || h_cached_inode != h_inode))
717
721
        return err;
718
722
}
719
723
 
720
 
static noinline_for_stack int
721
 
simple_reval_dpath(struct dentry *dentry, au_gen_t sgen)
 
724
static int simple_reval_dpath(struct dentry *dentry, au_gen_t sgen)
722
725
{
723
726
        int err;
724
727
        mode_t type;
745
748
                struct au_dpage *dpage;
746
749
                struct dentry **dentries;
747
750
 
748
 
                err = au_dpages_init(&dpages, GFP_TEMPORARY);
 
751
                err = au_dpages_init(&dpages, GFP_NOFS);
749
752
                AuDebugOn(err);
750
753
                err = au_dcsub_pages_rev(&dpages, parent, /*do_include*/1, NULL,
751
754
                                         NULL);
847
850
        AuDebugOn(!dentry->d_fsdata);
848
851
 
849
852
        err = -EINVAL;
 
853
        sb = dentry->d_sb;
 
854
        aufs_read_lock(dentry, AuLock_FLUSH | AuLock_DW);
 
855
 
850
856
        inode = dentry->d_inode;
851
 
        sb = dentry->d_sb;
852
 
        si_read_lock(sb, AuLock_FLUSH);
853
 
 
854
857
        sgen = au_sigen(sb);
855
 
        if (au_digen(dentry) == sgen)
856
 
                di_read_lock_child(dentry, !AuLock_IR);
857
 
        else {
 
858
        if (unlikely(au_digen(dentry) != sgen)) {
858
859
                AuDebugOn(IS_ROOT(dentry));
859
860
#ifdef ForceInotify
860
861
                AuDbg("UDBA or digen, %.*s\n", AuDLNPair(dentry));
861
862
#endif
862
 
                di_write_lock_child(dentry);
863
863
                if (inode)
864
864
                        err = au_reval_dpath(dentry, sgen);
865
 
                di_downgrade_lock(dentry, AuLock_IR);
866
865
                if (unlikely(err))
867
 
                        goto out;
868
 
                if (inode)
869
 
                        ii_read_unlock(inode);
 
866
                        goto out_dgrade;
870
867
                AuDebugOn(au_digen(dentry) != sgen);
871
868
        }
872
 
 
873
 
        if (inode) {
874
 
                if (au_iigen(inode) == sgen)
875
 
                        ii_read_lock_child(inode);
876
 
                else {
877
 
                        AuDebugOn(IS_ROOT(dentry));
 
869
        if (unlikely(inode && au_iigen(inode) != sgen)) {
 
870
                AuDebugOn(IS_ROOT(dentry));
878
871
#ifdef ForceInotify
879
 
                        AuDbg("UDBA or survived, %.*s\n", AuDLNPair(dentry));
 
872
                AuDbg("UDBA or survived, %.*s\n", AuDLNPair(dentry));
880
873
#endif
881
 
                        ii_write_lock_child(inode);
882
 
                        err = au_refresh_hinode(inode, dentry);
883
 
                        ii_downgrade_lock(inode);
884
 
                        if (unlikely(err))
885
 
                                goto out;
886
 
                        AuDebugOn(au_iigen(inode) != sgen);
887
 
                }
 
874
                err = au_refresh_hinode(inode, dentry);
 
875
                if (unlikely(err))
 
876
                        goto out_dgrade;
 
877
                AuDebugOn(au_iigen(inode) != sgen);
888
878
        }
 
879
        di_downgrade_lock(dentry, AuLock_IR);
889
880
 
890
881
#if 0 /* todo: support it? */
891
882
        /* parent dir i_nlink is not updated in the case of setattr */
909
900
                        goto out;
910
901
        }
911
902
        ndp = au_dup_nd(au_sbi(sb), &tmp_nd, nd);
 
903
#if 0
 
904
        if (nd) {
 
905
                path = nd->path;
 
906
                nd->path.dentry = au_h_dptr(nd->path.dentry, bindex);
 
907
        if (fake_nd->path.dentry) {
 
908
                fake_nd->path.mnt = au_sbr_mnt(sb, bindex);
 
909
                AuDebugOn(!fake_nd->path.mnt);
 
910
                path_get(&fake_nd->path);
 
911
                nd->path.
 
912
                        }
 
913
        }
 
914
#endif
912
915
        err = h_d_revalidate(dentry, inode, ndp, do_udba);
 
916
        goto out;
 
917
 
 
918
 out_dgrade:
 
919
        di_downgrade_lock(dentry, AuLock_IR);
913
920
 
914
921
 out:
915
922
        au_store_fmode_exec(nd, inode);
916
923
 
917
 
        if (inode)
918
 
                ii_read_unlock(inode);
919
 
        di_read_unlock(dentry, !AuLock_IR);
920
 
        si_read_unlock(sb);
 
924
        aufs_read_unlock(dentry, AuLock_IR);
921
925
        AuTraceErr(err);
922
926
        valid = !err;
923
927
        if (!valid)