~ubuntu-branches/ubuntu/quantal/aufs/quantal

« back to all changes in this revision

Viewing changes to fs/aufs/dentry.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2007-05-09 15:29:28 UTC
  • Revision ID: james.westby@ubuntu.com-20070509152928-4sywrmkifvz0bq02
Tags: upstream-0+20070509
ImportĀ upstreamĀ versionĀ 0+20070509

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005, 2006, 2007 Junjiro 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, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 */
 
18
 
 
19
/* $Id: dentry.h,v 1.24 2007/05/07 03:43:36 sfjro Exp $ */
 
20
 
 
21
#ifndef __AUFS_DENTRY_H__
 
22
#define __AUFS_DENTRY_H__
 
23
 
 
24
#include <linux/fs.h>
 
25
#include <linux/aufs_type.h>
 
26
#include "misc.h"
 
27
 
 
28
#ifdef __KERNEL__
 
29
 
 
30
struct aufs_hdentry {
 
31
        struct dentry   *hd_dentry;
 
32
};
 
33
 
 
34
struct aufs_dinfo {
 
35
        atomic_t                di_generation;
 
36
 
 
37
        struct aufs_rwsem       di_rwsem;
 
38
        aufs_bindex_t           di_bstart, di_bend, di_bwh, di_bdiropq;
 
39
        struct aufs_hdentry     *di_hdentry;
 
40
};
 
41
 
 
42
struct lkup_args {
 
43
        struct vfsmount *nfsmnt;
 
44
        int dlgt;
 
45
        //struct super_block *sb;
 
46
};
 
47
 
 
48
/* ---------------------------------------------------------------------- */
 
49
 
 
50
#if defined(CONFIG_AUFS_LHASH_PATCH) || defined(CONFIG_AUFS_DLGT)
 
51
struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
 
52
                        struct lkup_args *lkup);
 
53
#else
 
54
static inline
 
55
struct dentry *lkup_one(const char *name, struct dentry *parent, int len,
 
56
                        struct lkup_args *lkup)
 
57
{
 
58
        return lookup_one_len(name, parent, len);
 
59
}
 
60
#endif
 
61
 
 
62
extern struct dentry_operations aufs_dop;
 
63
struct dentry *sio_lkup_one(const char *name, struct dentry *parent, int len,
 
64
                            struct lkup_args *lkup);
 
65
int lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type);
 
66
int lkup_neg(struct dentry *dentry, aufs_bindex_t bindex);
 
67
int au_refresh_hdentry(struct dentry *dentry, mode_t type);
 
68
int au_reval_dpath(struct dentry *dentry, int sgen);
 
69
 
 
70
//dinfo.c
 
71
int au_alloc_dinfo(struct dentry *dentry);
 
72
struct aufs_dinfo *dtodi(struct dentry *dentry);
 
73
 
 
74
void di_read_lock(struct dentry *d, int flags, unsigned int lsc);
 
75
void di_read_unlock(struct dentry *d, int flags);
 
76
void di_downgrade_lock(struct dentry *d, int flags);
 
77
void di_write_lock(struct dentry *d, unsigned int lsc);
 
78
void di_write_unlock(struct dentry *d);
 
79
void di_write_lock2_child(struct dentry *d1, struct dentry *d2, int isdir);
 
80
void di_write_lock2_parent(struct dentry *d1, struct dentry *d2, int isdir);
 
81
void di_write_unlock2(struct dentry *d1, struct dentry *d2);
 
82
 
 
83
aufs_bindex_t dbstart(struct dentry *dentry);
 
84
aufs_bindex_t dbend(struct dentry *dentry);
 
85
aufs_bindex_t dbwh(struct dentry *dentry);
 
86
aufs_bindex_t dbdiropq(struct dentry *dentry);
 
87
struct dentry *au_h_dptr_i(struct dentry *dentry, aufs_bindex_t bindex);
 
88
struct dentry *au_h_dptr(struct dentry *dentry);
 
89
 
 
90
aufs_bindex_t dbtail(struct dentry *dentry);
 
91
aufs_bindex_t dbtaildir(struct dentry *dentry);
 
92
aufs_bindex_t dbtail_generic(struct dentry *dentry);
 
93
 
 
94
void set_dbstart(struct dentry *dentry, aufs_bindex_t bindex);
 
95
void set_dbend(struct dentry *dentry, aufs_bindex_t bindex);
 
96
void set_dbwh(struct dentry *dentry, aufs_bindex_t bindex);
 
97
void set_dbdiropq(struct dentry *dentry, aufs_bindex_t bindex);
 
98
void hdput(struct aufs_hdentry *hdentry);
 
99
void set_h_dptr(struct dentry *dentry, aufs_bindex_t bindex,
 
100
                struct dentry *h_dentry);
 
101
 
 
102
void au_update_digen(struct dentry *dentry);
 
103
void au_update_dbstart(struct dentry *dentry);
 
104
int au_find_dbindex(struct dentry *dentry, struct dentry *h_dentry);
 
105
 
 
106
/* ---------------------------------------------------------------------- */
 
107
 
 
108
static inline int au_digen(struct dentry *d)
 
109
{
 
110
        return atomic_read(&dtodi(d)->di_generation);
 
111
}
 
112
 
 
113
#ifdef CONFIG_AUFS_HINOTIFY
 
114
static inline void au_digen_dec(struct dentry *d)
 
115
{
 
116
        atomic_dec(&dtodi(d)->di_generation);
 
117
}
 
118
#endif /* CONFIG_AUFS_HINOTIFY */
 
119
 
 
120
/* ---------------------------------------------------------------------- */
 
121
 
 
122
/* lock subclass */
 
123
/* dinfo */
 
124
enum {
 
125
        AuLsc_DI_CHILD,         /* child first */
 
126
        AuLsc_DI_CHILD2,        /* rename(2), link(2), and cpup at hinotify */
 
127
        AuLsc_DI_CHILD3,        /* copyup dirs */
 
128
        AuLsc_DI_PARENT,
 
129
        AuLsc_DI_PARENT2,
 
130
        AuLsc_DI_PARENT3
 
131
};
 
132
 
 
133
#define ReadLockFunc(name, lsc) \
 
134
static inline void di_read_lock_##name(struct dentry *d, int flags) \
 
135
{di_read_lock(d, flags, AuLsc_DI_##lsc);}
 
136
 
 
137
#define WriteLockFunc(name, lsc) \
 
138
static inline void di_write_lock_##name(struct dentry *d) \
 
139
{di_write_lock(d, AuLsc_DI_##lsc);}
 
140
 
 
141
#define RWLockFuncs(name, lsc) \
 
142
        ReadLockFunc(name, lsc); \
 
143
        WriteLockFunc(name, lsc)
 
144
 
 
145
RWLockFuncs(child, CHILD);
 
146
RWLockFuncs(child2, CHILD2);
 
147
RWLockFuncs(child3, CHILD3);
 
148
RWLockFuncs(parent, PARENT);
 
149
RWLockFuncs(parent2, PARENT2);
 
150
RWLockFuncs(parent3, PARENT3);
 
151
 
 
152
#undef ReadLockFunc
 
153
#undef WriteLockFunc
 
154
#undef RWLockFunc
 
155
 
 
156
#define DiMustReadLock(d) do { \
 
157
        SiMustAnyLock((d)->d_sb); \
 
158
        RwMustReadLock(&dtodi(d)->di_rwsem); \
 
159
} while (0)
 
160
 
 
161
#define DiMustWriteLock(d) do { \
 
162
        SiMustAnyLock((d)->d_sb); \
 
163
        RwMustWriteLock(&dtodi(d)->di_rwsem); \
 
164
} while (0)
 
165
 
 
166
#define DiMustAnyLock(d) do { \
 
167
        SiMustAnyLock((d)->d_sb); \
 
168
        RwMustAnyLock(&dtodi(d)->di_rwsem); \
 
169
} while (0)
 
170
 
 
171
#define DiMustNoWaiters(d)      RwMustNoWaiters(&dtodi(d)->di_rwsem)
 
172
 
 
173
#endif /* __KERNEL__ */
 
174
#endif /* __AUFS_DENTRY_H__ */