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

« back to all changes in this revision

Viewing changes to fs/aufs/sbinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2005, 2006, 2007, 2008 Junjiro Okajima
 
2
 * Copyright (C) 2005-2008 Junjiro Okajima
3
3
 *
4
4
 * This program, aufs is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: sbinfo.c,v 1.48 2008/03/31 07:42:52 sfjro Exp $ */
 
19
/*
 
20
 * superblock private data
 
21
 *
 
22
 * $Id: sbinfo.c,v 1.50 2008/04/13 23:44:46 sfjro Exp $
 
23
 */
20
24
 
21
25
#include "aufs.h"
22
26
 
23
 
struct aufs_sbinfo *stosi(struct super_block *sb)
24
 
{
25
 
        struct aufs_sbinfo *sbinfo;
26
 
        sbinfo = sb->s_fs_info;
27
 
        //AuDebugOn(sbinfo->si_bend < 0);
28
 
        return sbinfo;
29
 
}
30
 
 
31
 
aufs_bindex_t sbend(struct super_block *sb)
32
 
{
33
 
        SiMustAnyLock(sb);
34
 
        return stosi(sb)->si_bend;
35
 
}
36
 
 
37
 
struct aufs_branch *stobr(struct super_block *sb, aufs_bindex_t bindex)
38
 
{
39
 
        struct aufs_branch *br;
40
 
 
41
 
        SiMustAnyLock(sb);
42
 
        AuDebugOn(bindex < 0 || sbend(sb) < bindex);
43
 
        br = stosi(sb)->si_branch[0 + bindex];
 
27
struct au_branch *au_sbr(struct super_block *sb, aufs_bindex_t bindex)
 
28
{
 
29
        struct au_branch *br;
 
30
 
 
31
        SiMustAnyLock(sb);
 
32
        AuDebugOn(bindex < 0 || au_sbend(sb) < bindex);
 
33
        br = au_sbi(sb)->si_branch[0 + bindex];
44
34
        AuDebugOn(!br);
45
35
        return br;
46
36
}
47
37
 
48
 
au_gen_t au_sigen(struct super_block *sb)
49
 
{
50
 
        SiMustAnyLock(sb);
51
 
        return stosi(sb)->si_generation;
52
 
}
53
 
 
54
38
au_gen_t au_sigen_inc(struct super_block *sb)
55
39
{
56
40
        au_gen_t gen;
57
41
 
58
42
        SiMustWriteLock(sb);
59
 
        gen = ++stosi(sb)->si_generation;
 
43
        gen = ++au_sbi(sb)->si_generation;
60
44
        au_update_digen(sb->s_root);
61
45
        au_update_iigen(sb->s_root->d_inode);
62
46
        sb->s_root->d_inode->i_version++;
63
47
        return gen;
64
48
}
65
49
 
66
 
int find_bindex(struct super_block *sb, struct aufs_branch *br)
 
50
int au_find_bindex(struct super_block *sb, struct au_branch *br)
67
51
{
68
52
        aufs_bindex_t bindex, bend;
69
53
 
70
 
        bend = sbend(sb);
 
54
        bend = au_sbend(sb);
71
55
        for (bindex = 0; bindex <= bend; bindex++)
72
 
                if (stobr(sb, bindex) == br)
 
56
                if (au_sbr(sb, bindex) == br)
73
57
                        return bindex;
74
58
        return -1;
75
59
}
111
95
{
112
96
        AuDebugOn(d1 == d2 || d1->d_sb != d2->d_sb);
113
97
        si_read_lock(d1->d_sb, flags);
114
 
        di_write_lock2_child(d1, d2, flags);
 
98
        di_write_lock2_child(d1, d2, au_ftest_lock(flags, DIR));
115
99
}
116
100
 
117
101
void aufs_read_and_write_unlock2(struct dentry *d1, struct dentry *d2)
123
107
 
124
108
/* ---------------------------------------------------------------------- */
125
109
 
126
 
aufs_bindex_t new_br_id(struct super_block *sb)
 
110
aufs_bindex_t au_new_br_id(struct super_block *sb)
127
111
{
128
112
        aufs_bindex_t br_id;
129
 
        struct aufs_sbinfo *sbinfo;
 
113
        struct au_sbinfo *sbinfo;
130
114
 
131
115
        AuTraceEnter();
132
116
        SiMustWriteLock(sb);
133
117
 
134
 
        sbinfo = stosi(sb);
 
118
        sbinfo = au_sbi(sb);
135
119
        while (1) {
136
120
                br_id = ++sbinfo->si_last_br_id;
137
 
                if (br_id && find_brindex(sb, br_id) < 0)
 
121
                if (br_id && au_br_index(sb, br_id) < 0)
138
122
                        return br_id;
139
123
        }
140
124
}