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

« back to all changes in this revision

Viewing changes to fs/aufs/i_op_ren.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: i_op_ren.c,v 1.68 2008/03/31 07:45:32 sfjro Exp $ */
 
19
/*
 
20
 * inode operation (rename entry)
 
21
 * this is monster
 
22
 *
 
23
 * $Id: i_op_ren.c,v 1.70 2008/04/13 23:42:46 sfjro Exp $
 
24
 */
20
25
 
21
26
#include "aufs.h"
22
27
 
30
35
#define au_ftest_ren(flags, name)       ((flags) & AuRen_##name)
31
36
#define au_fset_ren(flags, name)        { (flags) |= AuRen_##name; }
32
37
#define au_fclr_ren(flags, name)        { (flags) &= ~AuRen_##name; }
 
38
#ifndef CONFIG_AUFS_DLGT
 
39
#undef AuRen_DLGT
 
40
#define AuRen_DLGT      0
 
41
#endif
33
42
 
34
43
struct rename_args {
35
44
        struct dentry *h_dentry[2], *parent[2], *h_parent[2], *h_trap;
36
 
        struct aufs_nhash whlist;
 
45
        struct au_nhash whlist;
37
46
        aufs_bindex_t btgt, bstart[2];
38
47
        struct super_block *sb;
39
48
        unsigned int flags;
40
 
        unsigned int udba;
 
49
        unsigned int mnt_flags;
41
50
};
42
51
 
43
52
static int do_rename(struct inode *src_dir, struct dentry *src_dentry,
45
54
                     struct rename_args *a)
46
55
{
47
56
        int err, need_diropq, bycpup, rerr;
48
 
        struct rmdir_whtmp_args *thargs;
49
 
        struct dentry *wh_dentry[2], *h_dst;
 
57
        struct au_whtmp_rmdir_args *thargs;
 
58
        struct dentry *wh_dentry[2], *h_dst, *h_src;
50
59
        struct inode *h_dir[2];
51
60
        aufs_bindex_t bindex, bend;
52
 
        struct aufs_hin_ignore ign;
 
61
        struct au_hin_ignore ign;
53
62
        struct vfsub_args vargs;
54
 
        struct aufs_ndx ndx = {
 
63
        struct au_ndx ndx = {
55
64
                .flags  = 0,
56
65
                .nd     = NULL,
57
66
                //.br   = NULL
90
99
                au_fset_ndx(ndx.flags, DLGT);
91
100
        /* create whiteout for src_dentry */
92
101
        if (au_ftest_ren(a->flags, WHSRC)) {
93
 
                wh_dentry[SRC] = simple_create_wh(src_dir, src_dentry, a->btgt,
94
 
                                                  a->h_parent[SRC], &ndx);
 
102
                wh_dentry[SRC] = au_wh_create(src_dir, src_dentry, a->btgt,
 
103
                                              a->h_parent[SRC], &ndx);
95
104
                //wh_dentry[SRC] = ERR_PTR(-1);
96
105
                err = PTR_ERR(wh_dentry[SRC]);
97
106
                if (IS_ERR(wh_dentry[SRC]))
101
110
        /* lookup whiteout for dentry */
102
111
        if (au_ftest_ren(a->flags, WHDST)) {
103
112
                struct dentry *d;
104
 
                d = lkup_wh(a->h_parent[DST], &dentry->d_name, &ndx);
 
113
                d = au_wh_lkup(a->h_parent[DST], &dentry->d_name, &ndx);
105
114
                //d = ERR_PTR(-1);
106
115
                err = PTR_ERR(d);
107
116
                if (IS_ERR(d))
114
123
 
115
124
        /* rename dentry to tmpwh */
116
125
        if (thargs) {
117
 
                err = rename_whtmp(dir, dentry, a->btgt, /*noself*/0);
 
126
                err = au_whtmp_ren(dir, dentry, a->btgt, /*noself*/0);
118
127
                //err = -1;
119
128
                if (unlikely(err))
120
129
                        goto out_whdst;
121
 
                set_h_dptr(dentry, a->btgt, NULL);
 
130
                au_set_h_dptr(dentry, a->btgt, NULL);
122
131
                err = au_lkup_neg(dentry, a->btgt);
123
132
                //err = -1;
124
133
                if (unlikely(err))
140
149
        /* rename by vfs_rename or cpup */
141
150
        need_diropq = au_ftest_ren(a->flags, ISDIR)
142
151
                && (wh_dentry[DST]
143
 
                    || dbdiropq(dentry) == a->btgt
 
152
                    || au_dbdiropq(dentry) == a->btgt
144
153
                    /* hide the lower to keep xino */
145
 
                    || a->btgt < dbend(dentry)
146
 
                    || AuFlag(stosi(a->sb), f_always_diropq));
 
154
                    || a->btgt < au_dbend(dentry)
 
155
                    || au_opt_test(a->mnt_flags, ALWAYS_DIROPQ));
147
156
        bycpup = 0;
148
 
        if (dbstart(src_dentry) == a->btgt) {
149
 
                if (need_diropq && dbdiropq(src_dentry) == a->btgt)
 
157
        if (au_dbstart(src_dentry) == a->btgt) {
 
158
                if (need_diropq && au_dbdiropq(src_dentry) == a->btgt)
150
159
                        need_diropq = 0;
151
160
                vfsub_args_init(&vargs, &ign, au_ftest_ren(a->flags, DLGT), 0);
152
 
                if (unlikely(a->udba == AuUdba_INOTIFY
 
161
                if (unlikely(au_opt_test(a->mnt_flags, UDBA_INOTIFY)
153
162
                             && au_ftest_ren(a->flags, ISDIR)))
154
163
                        vfsub_ign_hinode(&vargs, IN_MOVE_SELF,
155
 
                                         itohi(src_dentry->d_inode, a->btgt));
 
164
                                         au_hi(src_dentry->d_inode, a->btgt));
156
165
                err = vfsub_rename(h_dir[SRC], au_h_dptr(src_dentry),
157
166
                                   h_dir[DST], a->h_dentry[DST], &vargs);
158
167
                //err = -1;
159
168
        } else {
160
169
                bycpup = 1;
161
170
                vfsub_i_lock_nested(a->h_dentry[SRC]->d_inode, AuLsc_I_CHILD);
162
 
                set_dbstart(src_dentry, a->btgt);
163
 
                set_h_dptr(src_dentry, a->btgt, dget(a->h_dentry[DST]));
 
171
                au_set_dbstart(src_dentry, a->btgt);
 
172
                au_set_h_dptr(src_dentry, a->btgt, dget(a->h_dentry[DST]));
164
173
                err = au_sio_cpup_single(src_dentry, a->btgt, a->bstart[SRC],
165
174
                                         -1, !AuCpup_DTIME);
166
175
                //err = -1; // untested dir
167
176
                if (unlikely(err)) {
168
 
                        set_h_dptr(src_dentry, a->btgt, NULL);
169
 
                        set_dbstart(src_dentry, a->bstart[SRC]);
 
177
                        au_set_h_dptr(src_dentry, a->btgt, NULL);
 
178
                        au_set_dbstart(src_dentry, a->bstart[SRC]);
170
179
                }
171
180
                vfsub_i_unlock(a->h_dentry[SRC]->d_inode);
172
181
        }
179
188
                struct inode *h_inode;
180
189
 
181
190
                h_inode = au_h_dptr_i(src_dentry, a->btgt)->d_inode;
182
 
                hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
183
 
                diropq = create_diropq(src_dentry, a->btgt,
184
 
                                       au_ftest_ren(a->flags, DLGT));
 
191
                au_hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
 
192
                diropq = au_diropq_create(src_dentry, a->btgt,
 
193
                                          au_ftest_ren(a->flags, DLGT));
185
194
                //diropq = ERR_PTR(-1);
186
 
                hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
 
195
                au_hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
187
196
                err = PTR_ERR(diropq);
188
197
                if (IS_ERR(diropq))
189
198
                        goto out_rename;
190
199
                dput(diropq);
191
200
        }
192
201
 
 
202
        /* update target timestamps */
 
203
        h_src = au_h_dptr(src_dentry);
 
204
        au_update_fuse_h_inode(NULL, h_src); /*ignore*/
 
205
        //src_dentry->d_inode->i_atime = h_src->d_inode->i_atime;
 
206
        src_dentry->d_inode->i_ctime = h_src->d_inode->i_ctime;
 
207
 
193
208
        /* remove whiteout for dentry */
194
209
        if (wh_dentry[DST]) {
195
 
                err = au_unlink_wh_dentry(h_dir[DST], wh_dentry[DST],
 
210
                err = au_wh_unlink_dentry(h_dir[DST], wh_dentry[DST],
196
211
                                          dentry, dir, /*dlgt*/0);
197
212
                //err = -1;
198
213
                if (unlikely(err))
203
218
        if (thargs) {
204
219
                if (au_test_nfs(h_dst->d_sb)
205
220
                    || !nhash_test_longer_wh(&a->whlist, a->btgt,
206
 
                                             stosi(a->sb)->si_dirwh)) {
207
 
                        err = rmdir_whtmp(h_dst, &a->whlist, a->btgt, dir,
208
 
                                          dentry->d_inode, /*noself*/0);
 
221
                                             au_sbi(a->sb)->si_dirwh)) {
 
222
                        err = au_whtmp_rmdir(h_dst, &a->whlist, a->btgt, dir,
 
223
                                             dentry->d_inode, /*noself*/0);
209
224
                        if (unlikely(err))
210
225
                                AuWarn("failed removing whtmp dir %.*s (%d), "
211
226
                                       "ignored.\n", AuDLNPair(h_dst), err);
212
227
                } else {
213
 
                        kick_rmdir_whtmp(h_dst, &a->whlist, a->btgt, dir,
214
 
                                         dentry->d_inode, /*noself*/0, thargs);
 
228
                        au_whtmp_kick_rmdir(h_dst, &a->whlist, a->btgt, dir,
 
229
                                            dentry->d_inode, /*noself*/0,
 
230
                                            thargs);
215
231
                        dput(h_dst);
216
232
                        thargs = NULL;
217
233
                }
230
246
                struct inode *h_inode;
231
247
 
232
248
                h_inode = au_h_dptr_i(src_dentry, a->btgt)->d_inode;
233
 
                //br_wh_read_lock(stobr(a->sb, a->btgt));
 
249
                //br_wh_read_lock(au_sbr(a->sb, a->btgt));
234
250
                /* i_lock simply since inotify is not set to h_inode. */
235
251
                vfsub_i_lock_nested(h_inode, AuLsc_I_PARENT);
236
 
                //hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
237
 
                rerr = remove_diropq(src_dentry, a->btgt,
238
 
                                     au_ftest_ren(a->flags, DLGT));
 
252
                //au_hdir_lock(h_inode, src_dentry->d_inode, a->btgt);
 
253
                rerr = au_diropq_remove(src_dentry, a->btgt,
 
254
                                        au_ftest_ren(a->flags, DLGT));
239
255
                //rerr = -1;
240
 
                //hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
 
256
                //au_hdir_unlock(h_inode, src_dentry->d_inode, a->btgt);
241
257
                vfsub_i_unlock(h_inode);
242
 
                //br_wh_read_unlock(stobr(a->sb, a->btgt));
 
258
                //br_wh_read_unlock(au_sbr(a->sb, a->btgt));
243
259
                if (rerr)
244
260
                        RevertFailure("remove diropq %.*s",
245
261
                                      AuDLNPair(src_dentry));
258
274
                }
259
275
                AuDebugOn(d->d_inode);
260
276
                vfsub_args_init(&vargs, &ign, au_ftest_ren(a->flags, DLGT), 0);
261
 
                if (unlikely(a->udba == AuUdba_INOTIFY
 
277
                if (unlikely(au_opt_test(a->mnt_flags, UDBA_INOTIFY)
262
278
                             && au_ftest_ren(a->flags, ISDIR)))
263
279
                        vfsub_ign_hinode(&vargs, IN_MOVE_SELF,
264
 
                                         itohi(src_dentry->d_inode, a->btgt));
 
280
                                         au_hi(src_dentry->d_inode, a->btgt));
265
281
                rerr = vfsub_rename
266
282
                        (h_dir[DST], au_h_dptr_i(src_dentry, a->btgt),
267
283
                         h_dir[SRC], d, &vargs);
268
284
                //rerr = -1;
269
285
                d_drop(d);
270
286
                dput(d);
271
 
                //set_h_dptr(src_dentry, a->btgt, NULL);
 
287
                //au_set_h_dptr(src_dentry, a->btgt, NULL);
272
288
                if (rerr)
273
289
                        RevertFailure("rename %.*s", AuDLNPair(src_dentry));
274
290
        } else {
275
291
                vfsub_args_init(&vargs, NULL, au_ftest_ren(a->flags, DLGT), 0);
276
292
                rerr = vfsub_unlink(h_dir[DST], a->h_dentry[DST], &vargs);
277
293
                //rerr = -1;
278
 
                set_h_dptr(src_dentry, a->btgt, NULL);
279
 
                set_dbstart(src_dentry, a->bstart[SRC]);
 
294
                au_set_h_dptr(src_dentry, a->btgt, NULL);
 
295
                au_set_dbstart(src_dentry, a->bstart[SRC]);
280
296
                if (rerr)
281
297
                        RevertFailure("unlink %.*s",
282
298
                                      AuDLNPair(a->h_dentry[DST]));
299
315
                }
300
316
                AuDebugOn(d->d_inode);
301
317
                vfsub_args_init(&vargs, &ign, au_ftest_ren(a->flags, DLGT), 0);
302
 
                if (unlikely(0 && a->udba == AuUdba_INOTIFY
 
318
                if (unlikely(0 && au_opt_test(a->mnt_flags, UDBA_INOTIFY)
303
319
                             && au_ftest_ren(a->flags, ISDIR)))
304
320
                        vfsub_ign_hinode(&vargs, IN_MOVE_SELF,
305
 
                                         itohi(dentry->d_inode, a->btgt));
 
321
                                         au_hi(dentry->d_inode, a->btgt));
306
322
                rerr = vfsub_rename(h_dir[DST], h_dst, h_dir[DST], d, &vargs);
307
323
                //rerr = -1;
308
324
                d_drop(d);
311
327
                        RevertFailure("rename %.*s", AuDLNPair(h_dst));
312
328
                        goto out_whdst;
313
329
                }
314
 
                set_h_dptr(dentry, a->btgt, NULL);
315
 
                set_h_dptr(dentry, a->btgt, dget(h_dst));
 
330
                au_set_h_dptr(dentry, a->btgt, NULL);
 
331
                au_set_h_dptr(dentry, a->btgt, dget(h_dst));
316
332
        }
317
333
 out_whdst:
318
334
        dput(wh_dentry[DST]);
319
335
        wh_dentry[DST] = NULL;
320
336
 out_whsrc:
321
337
        if (wh_dentry[SRC]) {
322
 
                rerr = au_unlink_wh_dentry(h_dir[SRC], wh_dentry[SRC],
 
338
                rerr = au_wh_unlink_dentry(h_dir[SRC], wh_dentry[SRC],
323
339
                                           src_dentry, src_dir, /*dlgt*/0);
324
340
                //rerr = -1;
325
341
                if (rerr)
327
343
        }
328
344
#undef RevertFailure
329
345
        d_drop(src_dentry);
330
 
        bend = dbend(src_dentry);
331
 
        for (bindex = dbstart(src_dentry); bindex <= bend; bindex++) {
 
346
        bend = au_dbend(src_dentry);
 
347
        for (bindex = au_dbstart(src_dentry); bindex <= bend; bindex++) {
332
348
                struct dentry *hd;
333
349
                hd = au_h_dptr_i(src_dentry, bindex);
334
350
                if (hd)
335
351
                        d_drop(hd);
336
352
        }
337
353
        d_drop(dentry);
338
 
        bend = dbend(dentry);
339
 
        for (bindex = dbstart(dentry); bindex <= bend; bindex++) {
 
354
        bend = au_dbend(dentry);
 
355
        for (bindex = au_dbstart(dentry); bindex <= bend; bindex++) {
340
356
                struct dentry *hd;
341
357
                hd = au_h_dptr_i(dentry, bindex);
342
358
                if (hd)
363
379
 * success means, it is a logically empty dir.
364
380
 */
365
381
static int may_rename_dstdir(struct dentry *dentry, aufs_bindex_t btgt,
366
 
                             struct aufs_nhash *whlist)
 
382
                             struct au_nhash *whlist)
367
383
{
368
384
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
369
385
 
385
401
 
386
402
        LKTRTrace("%.*s\n", AuDLNPair(dentry));
387
403
 
388
 
        bstart = dbstart(dentry);
 
404
        bstart = au_dbstart(dentry);
389
405
        if (bstart != btgt) {
390
 
                struct aufs_nhash *whlist;
 
406
                struct au_nhash *whlist;
391
407
 
392
408
                whlist = nhash_new(GFP_TEMPORARY);
393
409
                err = PTR_ERR(whlist);
398
414
                goto out;
399
415
        }
400
416
 
401
 
        if (bstart == dbtaildir(dentry))
 
417
        if (bstart == au_dbtaildir(dentry))
402
418
                return 0; /* success */
403
419
 
404
420
        err = au_test_empty_lower(dentry);
423
439
        parent = dentry->d_parent;
424
440
        IMustLock(parent->d_inode); /* dir is locked */
425
441
 
426
 
        bdiropq = dbdiropq(parent);
427
 
        bwh = dbwh(dentry);
428
 
        if (br_rdonly(stobr(dentry->d_sb, btgt))
 
442
        bdiropq = au_dbdiropq(parent);
 
443
        bwh = au_dbwh(dentry);
 
444
        if (au_br_rdonly(au_sbr(dentry->d_sb, btgt))
429
445
                     || (0 <= bdiropq && bdiropq < btgt)
430
446
                     || (0 <= bwh && bwh < btgt))
431
447
                btgt = -1;
435
451
}
436
452
 
437
453
//todo: meaningless lock if CONFIG_AUFS_DEBUG is disabled.
438
 
static void au_hgdirs(struct aufs_hinode **hgdir, struct rename_args *a)
 
454
static void au_hgdirs(struct au_hinode **hgdir, struct rename_args *a)
439
455
{
440
456
        struct dentry *gparent[2];
441
457
        struct inode *gdir;
442
458
 
443
 
        if (a->udba != AuUdba_INOTIFY)
 
459
        if (!au_opt_test(a->mnt_flags, UDBA_INOTIFY))
444
460
                return;
445
461
 
446
462
        gparent[SRC] = NULL;
449
465
                gdir = gparent[SRC]->d_inode;
450
466
                if (gparent[SRC] != a->parent[DST]) {
451
467
                        ii_read_lock_parent3(gdir);
452
 
                        hgdir[SRC] = itohi(gdir, a->btgt);
 
468
                        hgdir[SRC] = au_hi(gdir, a->btgt);
453
469
                        ii_read_unlock(gdir);
454
470
                } else
455
 
                        hgdir[SRC] = itohi(gdir, a->btgt);
 
471
                        hgdir[SRC] = au_hi(gdir, a->btgt);
456
472
                dput(gparent[SRC]);
457
473
        }
458
474
 
463
479
                gdir = gparent[DST]->d_inode;
464
480
                if (gparent[DST] != a->parent[SRC]) {
465
481
                        ii_read_lock_parent3(gdir);
466
 
                        hgdir[DST] = itohi(gdir, a->btgt);
 
482
                        hgdir[DST] = au_hi(gdir, a->btgt);
467
483
                        ii_read_unlock(gdir);
468
484
                } else
469
 
                        hgdir[DST] = itohi(gdir, a->btgt);
 
485
                        hgdir[DST] = au_hi(gdir, a->btgt);
470
486
                dput(gparent[DST]);
471
487
        }
472
488
}
477
493
 */
478
494
static int au_may_ren(struct inode *src_dir, struct dentry *src_dentry,
479
495
                      struct inode *dir, struct dentry *dentry,
480
 
                      struct rename_args *a, struct aufs_ndx *ndx)
 
496
                      struct rename_args *a, struct au_ndx *ndx)
481
497
{
482
498
        int err;
483
499
        struct inode *h_inode;
531
547
        int err, do_dt_dstdir, flags;
532
548
        aufs_bindex_t bend, bindex;
533
549
        struct inode *inode[2], *dirs[2];
534
 
        struct aufs_hinode *hgdir[2], *hdir;
 
550
        struct au_hinode *hgdir[2], *hdir;
535
551
        enum { PARENT, CHILD };
536
552
        /* reduce stack space */
537
553
        struct {
573
589
        }
574
590
 
575
591
        aufs_read_and_write_lock2(dentry, src_dentry, flags);
576
 
        if (unlikely(au_need_dlgt(p->a.sb)))
 
592
        p->a.mnt_flags = au_mntflags(p->a.sb);
 
593
        if (unlikely(au_opt_test_dlgt(p->a.mnt_flags)))
577
594
                au_fset_ren(p->a.flags, DLGT);
578
 
        p->a.udba = AuFlag(stosi(p->a.sb), f_udba);
579
595
        p->a.parent[SRC] = src_dentry->d_parent; /* dir inode is locked */
580
596
        p->a.parent[DST] = dentry->d_parent; /* dir inode is locked */
581
597
        if (src_dir == dir) {
586
602
                                      /*isdir*/1);
587
603
 
588
604
        /* which branch we process */
589
 
        p->a.bstart[SRC] = dbstart(src_dentry);
590
 
        p->a.bstart[DST] = dbstart(dentry);
 
605
        p->a.bstart[SRC] = au_dbstart(src_dentry);
 
606
        p->a.bstart[DST] = au_dbstart(dentry);
591
607
        if (au_ftest_ren(p->a.flags, ISDIR))
592
608
                au_fset_wrdir(wr_dir_args.flags, ISDIR);
593
609
        wr_dir_args.force_btgt = p->a.bstart[SRC];
603
619
        err = 0;
604
620
        nhash_init(&p->a.whlist);
605
621
        if (au_ftest_ren(p->a.flags, ISDIR) && inode[DST]) {
606
 
                set_dbstart(dentry, p->a.bstart[DST]);
 
622
                au_set_dbstart(dentry, p->a.bstart[DST]);
607
623
                err = may_rename_dstdir(dentry, p->a.btgt, &p->a.whlist);
608
 
                set_dbstart(dentry, p->a.btgt);
 
624
                au_set_dbstart(dentry, p->a.btgt);
609
625
        }
610
626
        p->a.h_dentry[DST] = au_h_dptr(dentry);
611
627
        if (unlikely(err))
646
662
        dirs[1] = dir;
647
663
 
648
664
        AuDbgSleep_UdbaRace();
649
 
        p->a.h_trap = hdir_lock_rename(p->a.h_parent, dirs, p->a.btgt,
650
 
                                       au_ftest_ren(p->a.flags, ISSAMEDIR));
 
665
        p->a.h_trap = au_hdir_lock_rename(p->a.h_parent, dirs, p->a.btgt,
 
666
                                          au_ftest_ren(p->a.flags, ISSAMEDIR));
651
667
 
652
 
        if (p->a.udba != AuUdba_NONE) {
653
 
                struct aufs_ndx ndx = {
 
668
        if (!au_opt_test(p->a.mnt_flags, UDBA_NONE)) {
 
669
                struct au_ndx ndx = {
654
670
                        .nfsmnt = au_nfsmnt(p->a.sb, p->a.btgt),
655
671
                        .flags  = 0,
656
672
                        .nd     = NULL,
672
688
        do_dt_dstdir = 0;
673
689
        if (au_ftest_ren(p->a.flags, ISDIR)) {
674
690
                hdir = NULL;
675
 
                if (unlikely(p->a.udba == AuUdba_INOTIFY))
676
 
                        hdir = itohi(p->a.parent[SRC]->d_inode, p->a.btgt);
677
 
                au_dtime_store
678
 
                        (p->dt[CHILD] + SRC, src_dentry, p->a.h_dentry[SRC],
679
 
                         hdir);
 
691
                if (unlikely(au_opt_test(p->a.mnt_flags, UDBA_INOTIFY)))
 
692
                        hdir = au_hi(p->a.parent[SRC]->d_inode, p->a.btgt);
 
693
                au_dtime_store(p->dt[CHILD] + SRC, src_dentry,
 
694
                               p->a.h_dentry[SRC], hdir);
680
695
                if (p->a.h_dentry[DST]->d_inode) {
681
696
                        do_dt_dstdir = 1;
682
 
                        if (unlikely(p->a.udba == AuUdba_INOTIFY))
683
 
                                hdir = itohi(p->a.parent[DST]->d_inode,
 
697
                        if (unlikely(au_opt_test(p->a.mnt_flags, UDBA_INOTIFY)))
 
698
                                hdir = au_hi(p->a.parent[DST]->d_inode,
684
699
                                             p->a.btgt);
685
 
                        au_dtime_store
686
 
                                (p->dt[CHILD] + DST, dentry, p->a.h_dentry[DST],
687
 
                                 hdir);
 
700
                        au_dtime_store(p->dt[CHILD] + DST, dentry,
 
701
                                       p->a.h_dentry[DST], hdir);
688
702
                }
689
703
        }
690
704
 
691
705
        err = do_rename(src_dir, src_dentry, dir, dentry, &p->a);
692
706
        if (unlikely(err))
693
707
                goto out_dt;
694
 
        hdir_unlock_rename(p->a.h_parent, dirs, p->a.btgt,
695
 
                           au_ftest_ren(p->a.flags, ISSAMEDIR));
 
708
        au_hdir_unlock_rename(p->a.h_parent, dirs, p->a.btgt,
 
709
                              au_ftest_ren(p->a.flags, ISSAMEDIR));
696
710
 
697
711
        /* update dir attributes */
698
712
        dir->i_version++;
708
722
                        au_cpup_attr_timesizes(inode[DST]);
709
723
                }
710
724
        }
711
 
        if (ibstart(dir) == p->a.btgt)
 
725
        if (au_ibstart(dir) == p->a.btgt)
712
726
                au_cpup_attr_timesizes(dir);
713
727
 
714
728
        if (!au_ftest_ren(p->a.flags, ISSAMEDIR)) {
715
729
                src_dir->i_version++;
716
730
                if (au_ftest_ren(p->a.flags, ISDIR))
717
731
                        au_cpup_attr_nlink(src_dir);
718
 
                if (ibstart(src_dir) == p->a.btgt)
 
732
                if (au_ibstart(src_dir) == p->a.btgt)
719
733
                        au_cpup_attr_timesizes(src_dir);
720
734
        }
721
735
 
723
737
        d_drop(src_dentry);
724
738
#else
725
739
        /* dput/iput all lower dentries */
726
 
        set_dbwh(src_dentry, -1);
727
 
        bend = dbend(src_dentry);
 
740
        au_set_dbwh(src_dentry, -1);
 
741
        bend = au_dbend(src_dentry);
728
742
        for (bindex = p->a.btgt + 1; bindex <= bend; bindex++) {
729
743
                struct dentry *hd;
730
744
                hd = au_h_dptr_i(src_dentry, bindex);
731
745
                if (hd)
732
 
                        set_h_dptr(src_dentry, bindex, NULL);
 
746
                        au_set_h_dptr(src_dentry, bindex, NULL);
733
747
        }
734
 
        set_dbend(src_dentry, p->a.btgt);
 
748
        au_set_dbend(src_dentry, p->a.btgt);
735
749
 
736
 
        bend = ibend(inode[SRC]);
 
750
        bend = au_ibend(inode[SRC]);
737
751
        for (bindex = p->a.btgt + 1; bindex <= bend; bindex++) {
738
752
                struct inode *hi;
739
753
                hi = au_h_iptr_i(inode[SRC], bindex);
740
754
                if (hi) {
741
755
                        //AuDbg("hi%lu, i%lu\n", hi->i_ino, 0LU);
742
 
                        xino_write0(p->a.sb, bindex, hi->i_ino, 0);
 
756
                        au_xino_write0(p->a.sb, bindex, hi->i_ino, 0);
743
757
                        /* ignore this error */
744
 
                        set_h_iptr(inode[SRC], bindex, NULL, 0);
 
758
                        au_set_h_iptr(inode[SRC], bindex, NULL, 0);
745
759
                }
746
760
        }
747
 
        set_ibend(inode[SRC], p->a.btgt);
 
761
        au_set_ibend(inode[SRC], p->a.btgt);
748
762
#endif
749
763
 
750
764
#if 0 // remove this
751
765
        if (inode[DST]) {
752
766
                struct inode *h_i;
753
767
 
754
 
                bend = ibend(inode[DST]);
755
 
                for (bindex = ibstart(inode[DST]); bindex <= bend; bindex++) {
 
768
                bend = au_ibend(inode[DST]);
 
769
                for (bindex = au_ibstart(inode[DST]); bindex <= bend;
 
770
                     bindex++) {
756
771
                        h_i = au_h_iptr_i(inode[DST], bindex);
757
772
                        if (h_i)
758
 
                                xino_write0(p->a.sb, bindex, h_i->i_ino, 0);
 
773
                                au_xino_write0(p->a.sb, bindex, h_i->i_ino, 0);
759
774
                        /* ignore this error */
760
775
                        /* bad action? */
761
776
                }
783
798
                }
784
799
        }
785
800
 out_hdir:
786
 
        hdir_unlock_rename(p->a.h_parent, dirs, p->a.btgt,
787
 
                           au_ftest_ren(p->a.flags, ISSAMEDIR));
 
801
        au_hdir_unlock_rename(p->a.h_parent, dirs, p->a.btgt,
 
802
                              au_ftest_ren(p->a.flags, ISSAMEDIR));
788
803
 out_children:
789
804
        nhash_fin(&p->a.whlist);
790
805
 out_unlock: