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

« back to all changes in this revision

Viewing changes to fs/aufs/finfo.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 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: finfo.c,v 1.31 2007/10/30 12:52:28 sfjro Exp $ */
 
19
/*
 
20
 * file private data
 
21
 *
 
22
 * $Id: finfo.c,v 1.33 2008/04/13 23:41:21 sfjro Exp $
 
23
 */
20
24
 
21
25
#include "aufs.h"
22
26
 
23
 
struct aufs_finfo *ftofi(struct file *file)
 
27
struct au_finfo *au_fi(struct file *file)
24
28
{
25
 
        struct aufs_finfo *finfo = file->private_data;
 
29
        struct au_finfo *finfo = file->private_data;
26
30
        AuDebugOn(!finfo
27
31
                  || !finfo->fi_hfile
28
32
                  || (0 < finfo->fi_bend
29
 
                      && (/* stosi(file->f_dentry->d_sb)->si_bend
 
33
                      && (/* au_sbi(file->f_dentry->d_sb)->si_bend
30
34
                             < finfo->fi_bend
31
35
                             || */ finfo->fi_bend < finfo->fi_bstart)));
32
36
        return finfo;
33
37
}
34
38
 
35
 
// hard/soft set
36
 
aufs_bindex_t fbstart(struct file *file)
37
 
{
38
 
        FiMustAnyLock(file);
39
 
        return ftofi(file)->fi_bstart;
40
 
}
41
 
 
42
 
aufs_bindex_t fbend(struct file *file)
43
 
{
44
 
        FiMustAnyLock(file);
45
 
        return ftofi(file)->fi_bend;
46
 
}
47
 
 
48
 
struct aufs_vdir *fvdir_cache(struct file *file)
49
 
{
50
 
        FiMustAnyLock(file);
51
 
        return ftofi(file)->fi_vdir_cache;
52
 
}
53
 
 
54
 
struct aufs_branch *ftobr(struct file *file, aufs_bindex_t bindex)
55
 
{
56
 
        struct aufs_finfo *finfo = ftofi(file);
57
 
        struct aufs_hfile *hf;
 
39
struct au_branch *au_fbr(struct file *file, aufs_bindex_t bindex)
 
40
{
 
41
        struct au_finfo *finfo = au_fi(file);
 
42
        struct au_hfile *hf;
58
43
 
59
44
        FiMustAnyLock(file);
60
45
        AuDebugOn(!finfo
62
47
                  || bindex < finfo->fi_bstart
63
48
                  || finfo->fi_bend < bindex);
64
49
        hf = finfo->fi_hfile + bindex;
65
 
        AuDebugOn(hf->hf_br && br_count(hf->hf_br) <= 0);
 
50
        AuDebugOn(hf->hf_br && au_br_count(hf->hf_br) <= 0);
66
51
        return hf->hf_br;
67
52
}
68
53
 
69
54
struct file *au_h_fptr_i(struct file *file, aufs_bindex_t bindex)
70
55
{
71
 
        struct aufs_finfo *finfo = ftofi(file);
72
 
        struct aufs_hfile *hf;
 
56
        struct au_finfo *finfo = au_fi(file);
 
57
        struct au_hfile *hf;
73
58
 
74
59
        FiMustAnyLock(file);
75
60
        AuDebugOn(!finfo
79
64
        hf = finfo->fi_hfile + bindex;
80
65
        AuDebugOn(hf->hf_file
81
66
                  && file_count(hf->hf_file) <= 0
82
 
                  && br_count(hf->hf_br) <= 0);
 
67
                  && au_br_count(hf->hf_br) <= 0);
83
68
        return hf->hf_file;
84
69
}
85
70
 
86
 
struct file *au_h_fptr(struct file *file)
87
 
{
88
 
        return au_h_fptr_i(file, fbstart(file));
89
 
}
90
 
 
91
 
void set_fbstart(struct file *file, aufs_bindex_t bindex)
92
 
{
93
 
        FiMustWriteLock(file);
94
 
        AuDebugOn(sbend(file->f_dentry->d_sb) < bindex);
95
 
        ftofi(file)->fi_bstart = bindex;
96
 
}
97
 
 
98
 
void set_fbend(struct file *file, aufs_bindex_t bindex)
99
 
{
100
 
        FiMustWriteLock(file);
101
 
        AuDebugOn(sbend(file->f_dentry->d_sb) < bindex
102
 
                  || bindex < fbstart(file));
103
 
        ftofi(file)->fi_bend = bindex;
104
 
}
105
 
 
106
 
void set_fvdir_cache(struct file *file, struct aufs_vdir *vdir_cache)
107
 
{
108
 
        FiMustWriteLock(file);
109
 
        AuDebugOn(!S_ISDIR(file->f_dentry->d_inode->i_mode)
110
 
                  || (ftofi(file)->fi_vdir_cache && vdir_cache));
111
 
        ftofi(file)->fi_vdir_cache = vdir_cache;
112
 
}
113
 
 
114
 
void au_hfput(struct aufs_hfile *hf)
 
71
void au_hfput(struct au_hfile *hf)
115
72
{
116
73
        if (hf->hf_file->f_mode & FMODE_EXEC)
117
74
                au_allow_write_access(hf->hf_file);
118
75
        fput(hf->hf_file);
119
76
        hf->hf_file = NULL;
120
77
        AuDebugOn(!hf->hf_br);
121
 
        br_put(hf->hf_br);
 
78
        au_br_put(hf->hf_br);
122
79
        hf->hf_br = NULL;
123
80
}
124
81
 
125
 
void set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *val)
 
82
void au_set_h_fptr(struct file *file, aufs_bindex_t bindex, struct file *val)
126
83
{
127
 
        struct aufs_finfo *finfo = ftofi(file);
128
 
        struct aufs_hfile *hf;
 
84
        struct au_finfo *finfo = au_fi(file);
 
85
        struct au_hfile *hf;
129
86
 
130
87
        FiMustWriteLock(file);
131
88
        AuDebugOn(!finfo
139
96
                au_hfput(hf);
140
97
        if (val) {
141
98
                hf->hf_file = val;
142
 
                hf->hf_br = stobr(file->f_dentry->d_sb, bindex);
 
99
                hf->hf_br = au_sbr(file->f_dentry->d_sb, bindex);
143
100
        }
144
101
}
145
102
 
146
 
void au_update_figen(struct file *file)
147
 
{
148
 
        atomic_set(&ftofi(file)->fi_generation, au_digen(file->f_dentry));
149
 
        //smp_mb(); /* atomic_set */
150
 
}
151
 
 
152
103
void au_finfo_fin(struct file *file)
153
104
{
154
 
        struct aufs_finfo *finfo;
 
105
        struct au_finfo *finfo;
155
106
        struct dentry *dentry;
156
107
        aufs_bindex_t bindex, bend;
157
108
 
160
111
        SiMustAnyLock(dentry->d_sb);
161
112
 
162
113
        fi_write_lock(file);
163
 
        bend = fbend(file);
164
 
        bindex = fbstart(file);
 
114
        bend = au_fbend(file);
 
115
        bindex = au_fbstart(file);
165
116
        if (bindex >= 0)
166
117
                for (; bindex <= bend; bindex++)
167
 
                        set_h_fptr(file, bindex, NULL);
 
118
                        au_set_h_fptr(file, bindex, NULL);
168
119
 
169
 
        finfo = ftofi(file);
 
120
        finfo = au_fi(file);
170
121
#ifdef CONFIG_AUFS_DEBUG
171
122
        if (finfo->fi_bstart >= 0) {
172
 
                bend = fbend(file);
 
123
                bend = au_fbend(file);
173
124
                for (bindex = finfo->fi_bstart; bindex <= bend; bindex++) {
174
 
                        struct aufs_hfile *hf;
 
125
                        struct au_hfile *hf;
175
126
                        hf = finfo->fi_hfile + bindex;
176
127
                        AuDebugOn(hf->hf_file || hf->hf_br);
177
128
                }
186
137
 
187
138
int au_finfo_init(struct file *file)
188
139
{
189
 
        struct aufs_finfo *finfo;
 
140
        struct au_finfo *finfo;
190
141
        struct dentry *dentry;
191
142
        union {
192
143
                void *p;
199
150
 
200
151
        finfo = au_cache_alloc_finfo();
201
152
        if (finfo) {
202
 
                finfo->fi_hfile = kcalloc(sbend(dentry->d_sb) + 1,
 
153
                finfo->fi_hfile = kcalloc(au_sbend(dentry->d_sb) + 1,
203
154
                                          sizeof(*finfo->fi_hfile), GFP_KERNEL);
204
155
                if (finfo->fi_hfile) {
205
 
                        rw_init_wlock(&finfo->fi_rwsem);
 
156
                        au_rw_init_wlock(&finfo->fi_rwsem);
206
157
                        finfo->fi_bstart = -1;
207
158
                        finfo->fi_bend = -1;
208
159
                        atomic_set(&finfo->fi_generation, au_digen(dentry));