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

« back to all changes in this revision

Viewing changes to fs/aufs25/dir.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-08-21 14:58:54 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20080821145854-a2qpyyfjwtbmarqj
Tags: upstream-0+20080719
ImportĀ upstreamĀ versionĀ 0+20080719

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
/*
20
20
 * directory operations
21
21
 *
22
 
 * $Id: dir.c,v 1.6 2008/06/02 02:38:21 sfjro Exp $
 
22
 * $Id: dir.c,v 1.9 2008/07/14 00:18:23 sfjro Exp $
23
23
 */
24
24
 
25
25
#include <linux/fs_stack.h>
113
113
                return 0; /* success */
114
114
 
115
115
        /* close all */
116
 
        for (bindex = au_fbstart(file); !err && bindex <= btail; bindex++)
 
116
        for (bindex = au_fbstart(file); bindex <= btail; bindex++)
117
117
                au_set_h_fptr(file, bindex, NULL);
118
118
        au_set_fbstart(file, -1);
119
119
        au_set_fbend(file, -1);
213
213
        sb = dentry->d_sb;
214
214
        si_noflush_read_lock(sb);
215
215
        if (file) {
216
 
                err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
217
 
                                              /*locked*/1);
 
216
                err = au_reval_and_lock_fdi(file, reopen_dir, /*wlock*/1,
 
217
                                        /*locked*/1);
218
218
                if (unlikely(err))
219
219
                        goto out;
220
220
        } else
221
 
                di_read_lock_child(dentry, !AuLock_IW);
 
221
                di_write_lock_child(dentry);
222
222
 
223
 
        ii_write_lock_child(inode);
224
223
        if (file) {
225
224
                bend = au_fbend(file);
226
225
                for (bindex = au_fbstart(file); !err && bindex <= bend;
246
245
        } else
247
246
                err = fsync_dir(dentry, datasync);
248
247
        au_cpup_attr_timesizes(inode);
249
 
        ii_write_unlock(inode);
 
248
        di_write_unlock(dentry);
250
249
        if (file)
251
250
                fi_write_unlock(file);
252
 
        else
253
 
                di_read_unlock(dentry, !AuLock_IW);
254
251
 
255
252
 out:
256
253
        si_read_unlock(sb);
262
259
 
263
260
static int aufs_readdir(struct file *file, void *dirent, filldir_t filldir)
264
261
{
265
 
        int err;
 
262
        int err, iflag;
266
263
        struct dentry *dentry;
267
264
        struct inode *inode;
268
265
        struct super_block *sb;
275
272
        au_nfsd_lockdep_off();
276
273
        sb = dentry->d_sb;
277
274
        si_read_lock(sb, AuLock_FLUSH);
278
 
        err = au_reval_and_lock_finfo(file, reopen_dir, /*wlock*/1,
279
 
                                      /*locked*/1);
 
275
        err = au_reval_and_lock_fdi(file, reopen_dir, /*wlock*/1, /*locked*/1);
280
276
        if (unlikely(err))
281
277
                goto out;
282
278
 
283
 
        ii_write_lock_child(inode);
284
279
        err = au_vdir_init(file);
285
280
        if (unlikely(err)) {
286
 
                ii_write_unlock(inode);
 
281
                di_write_unlock(dentry);
287
282
                goto out_unlock;
288
283
        }
289
284
 
290
285
        /* nfsd filldir calls lookup_one_len(). */
291
 
        ii_downgrade_lock(inode);
 
286
        iflag = AuLock_IW;
 
287
        if (unlikely(au_test_nfsd(current)))
 
288
                iflag = AuLock_IR;
 
289
        di_downgrade_lock(dentry, iflag);
292
290
        err = au_vdir_fill_de(file, dirent, filldir);
293
291
 
294
292
        fsstack_copy_attr_atime(inode, au_h_iptr(inode, au_ibstart(inode)));
295
 
        ii_read_unlock(inode);
 
293
        di_read_unlock(dentry, iflag);
296
294
 
297
295
 out_unlock:
298
296
        fi_write_unlock(file);
430
428
        h_inode = h_dentry->d_inode;
431
429
        AuDebugOn(!h_inode || !S_ISDIR(h_inode->i_mode));
432
430
 
 
431
        /* todo: move this lock to the callers of this function */
433
432
        mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
434
433
        err = au_test_h_perm_sio(h_inode, MAY_EXEC | MAY_READ,
435
434
                                 au_test_dlgt(au_mntflags(dentry->d_sb)));
468
467
        inode = dentry->d_inode;
469
468
        AuDebugOn(!inode || !S_ISDIR(inode->i_mode));
470
469
 
471
 
        whlist = au_nhash_new(GFP_TEMPORARY);
 
470
        whlist = au_nhash_new(GFP_NOFS);
472
471
        err = PTR_ERR(whlist);
473
472
        if (IS_ERR(whlist))
474
473
                goto out;