27
31
| IN_DELETE_SELF | IN_MOVE_SELF);
28
32
static struct inotify_handle *in_handle;
30
int au_hin_alloc(struct aufs_hinode *hinode, struct inode *inode,
34
/* the size of an array for ignore counter */
35
static int au_hin_nignore;
37
AuCacheFuncs(hinotify, AuCache_HINOTIFY);
39
int au_hin_alloc(struct au_hinode *hinode, struct inode *inode,
31
40
struct inode *hidden_inode)
34
struct aufs_hinotify *hin;
43
struct au_hinotify *hin;
37
46
LKTRTrace("i%lu, hi%lu\n", inode->i_ino, hidden_inode->i_ino);
120
129
void au_do_hdir_lock(struct inode *h_dir, struct inode *dir,
121
130
aufs_bindex_t bindex, unsigned int lsc)
123
struct aufs_hinode *hinode;
132
struct au_hinode *hinode;
125
134
LKTRTrace("i%lu, b%d, lsc %d\n", dir->i_ino, bindex, lsc);
126
135
AuDebugOn(!S_ISDIR(dir->i_mode));
127
hinode = itoii(dir)->ii_hinode + bindex;
136
hinode = au_ii(dir)->ii_hinode + bindex;
128
137
AuDebugOn(h_dir != hinode->hi_inode);
130
139
vfsub_i_lock_nested(h_dir, lsc);
131
140
suspend_hinotify(hinode);
134
void hdir_unlock(struct inode *h_dir, struct inode *dir, aufs_bindex_t bindex)
143
void au_hdir_unlock(struct inode *h_dir, struct inode *dir,
144
aufs_bindex_t bindex)
136
struct aufs_hinode *hinode;
146
struct au_hinode *hinode;
138
148
LKTRTrace("i%lu, b%d\n", dir->i_ino, bindex);
139
149
AuDebugOn(!S_ISDIR(dir->i_mode));
140
hinode = itoii(dir)->ii_hinode + bindex;
150
hinode = au_ii(dir)->ii_hinode + bindex;
141
151
AuDebugOn(h_dir != hinode->hi_inode);
143
153
resume_hinotify(hinode);
144
154
vfsub_i_unlock(h_dir);
147
struct dentry *hdir_lock_rename(struct dentry **h_parents, struct inode **dirs,
148
aufs_bindex_t bindex, int issamedir)
157
struct dentry *au_hdir_lock_rename(struct dentry **h_parents,
158
struct inode **dirs, aufs_bindex_t bindex,
150
161
struct dentry *h_trap;
151
struct aufs_hinode *hinode;
162
struct au_hinode *hinode;
153
164
LKTRTrace("%.*s, %.*s\n",
154
165
AuDLNPair(h_parents[0]), AuDLNPair(h_parents[1]));
156
167
h_trap = vfsub_lock_rename(h_parents[0], h_parents[1]);
157
hinode = itoii(dirs[0])->ii_hinode + bindex;
168
hinode = au_ii(dirs[0])->ii_hinode + bindex;
158
169
AuDebugOn(h_parents[0]->d_inode != hinode->hi_inode);
159
170
suspend_hinotify(hinode);
160
171
if (!issamedir) {
161
hinode = itoii(dirs[1])->ii_hinode + bindex;
172
hinode = au_ii(dirs[1])->ii_hinode + bindex;
162
173
AuDebugOn(h_parents[1]->d_inode != hinode->hi_inode);
163
174
suspend_hinotify(hinode);
169
void hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
170
aufs_bindex_t bindex, int issamedir)
180
void au_hdir_unlock_rename(struct dentry **h_parents, struct inode **dirs,
181
aufs_bindex_t bindex, int issamedir)
172
struct aufs_hinode *hinode;
183
struct au_hinode *hinode;
174
185
LKTRTrace("%.*s, %.*s\n",
175
186
AuDLNPair(h_parents[0]), AuDLNPair(h_parents[1]));
177
hinode = itoii(dirs[0])->ii_hinode + bindex;
188
hinode = au_ii(dirs[0])->ii_hinode + bindex;
178
189
AuDebugOn(h_parents[0]->d_inode != hinode->hi_inode);
179
190
resume_hinotify(hinode);
180
191
if (!issamedir) {
181
hinode = itoii(dirs[1])->ii_hinode + bindex;
192
hinode = au_ii(dirs[1])->ii_hinode + bindex;
182
193
AuDebugOn(h_parents[1]->d_inode != hinode->hi_inode);
183
194
resume_hinotify(hinode);
194
205
LKTRTrace("i%lu, 0x%x\n", inode->i_ino, flags);
197
for (bindex = ibstart(inode); bindex <= bend; bindex++) {
207
bend = au_ibend(inode);
208
for (bindex = au_ibstart(inode); bindex <= bend; bindex++) {
198
209
hi = au_h_iptr_i(inode, bindex);
200
211
//vfsub_i_lock_nested(hi, AuLsc_I_CHILD);
202
213
if (unlikely(iwhdentry))
205
set_h_iptr(inode, bindex, NULL, 0);
206
set_h_iptr(inode, bindex, igrab(hi),
216
au_set_h_iptr(inode, bindex, NULL, 0);
217
au_set_h_iptr(inode, bindex, igrab(hi),
210
221
//vfsub_i_unlock(hi);
215
226
/* ---------------------------------------------------------------------- */
217
void au_hin_ignore(struct aufs_hinode *hinode, __u32 events)
228
/* cf. fsnotify_change() */
229
__u32 vfsub_events_notify_change(struct iattr *ia)
232
const unsigned int amtime = (ATTR_ATIME | ATTR_MTIME);
235
if ((ia->ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE))
236
|| (ia->ia_valid & amtime) == amtime)
238
if ((ia->ia_valid & ATTR_SIZE)
239
|| (ia->ia_valid & amtime) == ATTR_MTIME)
244
void vfsub_ign_hinode(struct vfsub_args *vargs, __u32 events,
245
struct au_hinode *hinode)
247
struct au_hin_ignore *ign;
251
ign = vargs->ignore + vargs->nignore++;
252
ign->ign_events = events;
253
ign->ign_hinode = hinode;
256
void vfsub_ignore(struct vfsub_args *vargs)
259
struct au_hin_ignore *ign;
264
au_hin_ignore(ign->ign_hinode, ign->ign_events);
269
void vfsub_unignore(struct vfsub_args *vargs)
272
struct au_hin_ignore *ign;
277
au_hin_unignore(ign->ign_hinode, ign->ign_events);
282
/* ---------------------------------------------------------------------- */
284
void au_hin_ignore(struct au_hinode *hinode, __u32 events)
317
384
list_for_each_entry(d, &parent->d_subdirs, d_u.d_child) {
318
385
LKTRTrace("%.*s\n", AuDLNPair(d));
319
386
dname = &d->d_name;
320
if (dname->len != nlen
321
|| memcmp(dname->name, name, nlen))
387
if (dname->len != nlen || memcmp(dname->name, name, nlen))
323
389
if (!atomic_read(&d->d_count)) {
324
390
spin_lock(&d->d_lock);
342
408
aufs_bindex_t bindex, ino_t h_ino)
344
410
struct inode *inode;
345
struct xino_entry xinoe;
411
struct au_xino_entry xinoe;
348
414
LKTRTrace("b%d, hi%lu\n", bindex, h_ino);
349
AuDebugOn(AuFlag(stosi(sb), f_xino) == AuXino_NONE);
415
AuDebugOn(!au_opt_test(au_mntflags(sb), XINO));
352
err = xino_read(sb, bindex, h_ino, &xinoe);
418
err = au_xino_read(sb, bindex, h_ino, &xinoe);
353
419
if (!err && xinoe.ino)
354
420
inode = ilookup(sb, xinoe.ino);
415
481
for (bindex = bstart; bindex <= bend; bindex++) {
416
482
h_i = au_h_iptr_i(inode, bindex);
418
err = xino_write0(inode->i_sb, bindex, h_i->i_ino, 0);
484
err = au_xino_write0(inode->i_sb, bindex, h_i->i_ino,
419
486
/* ignore this error */
420
487
/* bad action? */
695
761
// do not lock here because of d_revalidate() may cause a deadlock.
696
762
//vfsub_i_lock(a->dir);
697
763
sb = a->dir->i_sb;
699
765
/* big aufs lock */
700
766
si_noflush_write_lock(sb);
702
768
ii_read_lock_parent(a->dir);
704
bend = ibend(a->dir);
705
for (bindex = ibstart(a->dir); bindex <= bend; bindex++)
770
bend = au_ibend(a->dir);
771
for (bindex = au_ibstart(a->dir); bindex <= bend; bindex++)
706
772
if (au_h_iptr_i(a->dir, bindex) == a->h_dir) {
780
846
u32 cookie, const char *h_child_name,
781
847
struct inode *h_child_inode)
783
struct aufs_hinotify *hinotify;
849
struct au_hinotify *hinotify;
784
850
struct postproc_args *args;
785
851
int len, wkq_err, isdir, isroot, wh, idx;
819
hinotify = container_of(watch, struct aufs_hinotify, hin_watch);
885
hinotify = container_of(watch, struct au_hinotify, hin_watch);
820
886
AuDebugOn(!hinotify || !hinotify->hin_aufs_inode);
821
887
idx = ilog2(mask & IN_ALL_EVENTS);
822
888
AuDebugOn(au_hin_nignore <= idx);
975
au_nwt_inc(&stosi(sb)->si_nowait);
1045
au_nwt_inc(&au_sbi(sb)->si_nowait);
977
1047
wkq_err = au_wkq_nowait(postproc, args, sb, /*dlgt*/0);
979
1049
if (unlikely(wkq_err)) {
980
1050
AuErr("wkq %d\n", wkq_err);
981
au_nwt_dec(&stosi(sb)->si_nowait);
1051
au_nwt_dec(&au_sbi(sb)->si_nowait);
1002
1078
//AuDbg("au_hin_nignore %d\n", au_hin_nignore);
1003
1079
AuDebugOn(au_hin_nignore != 12);
1081
in_handle = ERR_PTR(-ENOMEM);
1082
au_cachep[AuCache_HINOTIFY]
1083
= AuCacheX(au_hinotify, sizeof(atomic_t) * au_hin_nignore);
1084
if (unlikely(!au_cachep[AuCache_HINOTIFY]))
1005
1087
in_handle = inotify_init(&aufs_inotify_ops);
1006
1088
if (!IS_ERR(in_handle))
1091
au_hin_destroy_cache();
1008
1093
AuTraceErrPtr(in_handle);
1009
1094
return PTR_ERR(in_handle);