Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'aufs2-33' into aufs2-34
Browse files Browse the repository at this point in the history
  • Loading branch information
J. R. Okajima committed Jun 13, 2010
2 parents 7a8a078 + 8ac89b3 commit bb3338d
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 104 deletions.
17 changes: 7 additions & 10 deletions fs/aufs/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,10 @@ int au_br_add(struct super_block *sb, struct au_opt_add *add, int remount)
* test if the branch is deletable or not.
*/
static int test_dentry_busy(struct dentry *root, aufs_bindex_t bindex,
unsigned int sigen)
unsigned int sigen, const unsigned int verbose)
{
int err, i, j, ndentry;
aufs_bindex_t bstart, bend;
unsigned char verbose;
struct au_dcsub_pages dpages;
struct au_dpage *dpage;
struct dentry *d;
Expand All @@ -543,7 +542,6 @@ static int test_dentry_busy(struct dentry *root, aufs_bindex_t bindex,
if (unlikely(err))
goto out_dpages;

verbose = !!au_opt_test(au_mntflags(root->d_sb), VERBOSE);
for (i = 0; !err && i < dpages.ndpage; i++) {
dpage = dpages.dpages + i;
ndentry = dpage->ndentry;
Expand Down Expand Up @@ -584,15 +582,13 @@ static int test_dentry_busy(struct dentry *root, aufs_bindex_t bindex,
}

static int test_inode_busy(struct super_block *sb, aufs_bindex_t bindex,
unsigned int sigen)
unsigned int sigen, const unsigned int verbose)
{
int err;
struct inode *i;
aufs_bindex_t bstart, bend;
unsigned char verbose;

err = 0;
verbose = !!au_opt_test(au_mntflags(sb), VERBOSE);
list_for_each_entry(i, &sb->s_inodes, i_sb_list) {
AuDebugOn(!atomic_read(&i->i_count));
if (!list_empty(&i->i_dentry))
Expand Down Expand Up @@ -628,7 +624,8 @@ static int test_inode_busy(struct super_block *sb, aufs_bindex_t bindex,
return err;
}

static int test_children_busy(struct dentry *root, aufs_bindex_t bindex)
static int test_children_busy(struct dentry *root, aufs_bindex_t bindex,
const unsigned int verbose)
{
int err;
unsigned int sigen;
Expand All @@ -637,9 +634,9 @@ static int test_children_busy(struct dentry *root, aufs_bindex_t bindex)
DiMustNoWaiters(root);
IiMustNoWaiters(root->d_inode);
di_write_unlock(root);
err = test_dentry_busy(root, bindex, sigen);
err = test_dentry_busy(root, bindex, sigen, verbose);
if (!err)
err = test_inode_busy(root->d_sb, bindex, sigen);
err = test_inode_busy(root->d_sb, bindex, sigen, verbose);
di_write_lock_child(root); /* aufs_write_lock() calls ..._child() */

return err;
Expand Down Expand Up @@ -776,7 +773,7 @@ int au_br_del(struct super_block *sb, struct au_opt_del *del, int remount)
}
}

err = test_children_busy(sb->s_root, bindex);
err = test_children_busy(sb->s_root, bindex, verbose);
if (unlikely(err)) {
if (do_wh)
goto out_wh;
Expand Down
3 changes: 1 addition & 2 deletions fs/aufs/branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ ssize_t xino_fwrite(au_writef_t func, struct file *file, void *buf, size_t size,
struct file *au_xino_create2(struct file *base_file, struct file *copy_src);
struct file *au_xino_create(struct super_block *sb, char *fname, int silent);
ino_t au_xino_new_ino(struct super_block *sb);
int au_xino_write0(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
ino_t ino);
void au_xino_delete_inode(struct inode *inode, const int unlinked);
int au_xino_write(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
ino_t ino);
int au_xino_read(struct super_block *sb, aufs_bindex_t bindex, ino_t h_ino,
Expand Down
23 changes: 5 additions & 18 deletions fs/aufs/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,28 @@ static int au_test_anon(struct dentry *dentry)
/* ---------------------------------------------------------------------- */
/* inode generation external table */

int au_xigen_inc(struct inode *inode)
void au_xigen_inc(struct inode *inode)
{
int err;
loff_t pos;
ssize_t sz;
__u32 igen;
struct super_block *sb;
struct au_sbinfo *sbinfo;

err = 0;
sb = inode->i_sb;
sbinfo = au_sbi(sb);
/*
* temporary workaround for escaping from SiMustAnyLock() in
* au_mntflags(), since this function is called from au_iinfo_fin().
*/
if (unlikely(!au_opt_test(sbinfo->si_mntflags, XINO)))
goto out;
AuDebugOn(!au_opt_test(au_mntflags(sb), XINO));

sbinfo = au_sbi(sb);
pos = inode->i_ino;
pos *= sizeof(igen);
igen = inode->i_generation + 1;
sz = xino_fwrite(sbinfo->si_xwrite, sbinfo->si_xigen, &igen,
sizeof(igen), &pos);
if (sz == sizeof(igen))
goto out; /* success */
return; /* success */

err = sz;
if (unlikely(sz >= 0)) {
err = -EIO;
if (unlikely(sz >= 0))
AuIOErr("xigen error (%zd)\n", sz);
}

out:
return err;
}

int au_xigen_new(struct inode *inode)
Expand Down
4 changes: 2 additions & 2 deletions fs/aufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ int au_do_flush(struct file *file, fl_owner_t id,
inode = dentry->d_inode;
si_noflush_read_lock(sb);
fi_read_lock(file);
di_read_lock_child(dentry, AuLock_IW);
ii_read_lock_child(inode);

err = flush(file, id);
au_cpup_attr_timesizes(inode);

di_read_unlock(dentry, AuLock_IW);
ii_read_unlock(inode);
fi_read_unlock(file);
si_read_unlock(sb);
return err;
Expand Down
55 changes: 13 additions & 42 deletions fs/aufs/iinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,67 +211,38 @@ int au_ii_realloc(struct au_iinfo *iinfo, int nbr)
return err;
}

static int au_iinfo_write0(struct super_block *sb, struct au_hinode *hinode,
ino_t ino)
{
int err;
aufs_bindex_t bindex;
unsigned char locked;

err = 0;
locked = !!si_noflush_read_trylock(sb);
bindex = au_br_index(sb, hinode->hi_id);
if (bindex >= 0)
err = au_xino_write0(sb, bindex, hinode->hi_inode->i_ino, ino);
/* error action? */
if (locked)
si_read_unlock(sb);
return err;
}

void au_iinfo_fin(struct inode *inode)
{
ino_t ino;
aufs_bindex_t bend;
unsigned char unlinked = !inode->i_nlink;
struct au_iinfo *iinfo;
struct au_hinode *hi;
struct super_block *sb;

if (unlinked) {
int err = au_xigen_inc(inode);
if (unlikely(err))
AuWarn1("failed resetting i_generation, %d\n", err);
}
aufs_bindex_t bindex, bend;
unsigned char locked;

iinfo = au_ii(inode);
/* bad_inode case */
if (!iinfo)
return;

sb = inode->i_sb;
locked = !!si_noflush_read_trylock(sb);
au_xino_delete_inode(inode, !inode->i_nlink);
if (locked)
si_read_unlock(sb);

if (iinfo->ii_vdir)
au_vdir_free(iinfo->ii_vdir);

if (iinfo->ii_bstart >= 0) {
sb = inode->i_sb;
ino = 0;
if (unlinked)
ino = inode->i_ino;
hi = iinfo->ii_hinode + iinfo->ii_bstart;
bindex = iinfo->ii_bstart;
if (bindex >= 0) {
hi = iinfo->ii_hinode + bindex;
bend = iinfo->ii_bend;
while (iinfo->ii_bstart++ <= bend) {
if (hi->hi_inode) {
if (unlinked || !hi->hi_inode->i_nlink) {
au_iinfo_write0(sb, hi, ino);
/* ignore this error */
ino = 0;
}
while (bindex++ <= bend) {
if (hi->hi_inode)
au_hiput(hi);
}
hi++;
}
}

kfree(iinfo->ii_hinode);
AuRwDestroy(&iinfo->ii_rwsem);
}
13 changes: 9 additions & 4 deletions fs/aufs/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1,
/* true if a kernel thread named 'loop[0-9].*' accesses a file */
int au_test_loopback_kthread(void)
{
const char c = current->comm[4];
int ret;

return current->mm == NULL
&& '0' <= c && c <= '9'
&& strncmp(current->comm, "loop", 4) == 0;
ret = 0;
if (current->flags & PF_KTHREAD) {
const char c = current->comm[4];
ret = ('0' <= c && c <= '9'
&& !strncmp(current->comm, "loop", 4));
}

return ret;
}
4 changes: 1 addition & 3 deletions fs/aufs/plink.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,13 @@ long au_plink_ioctl(struct file *file, unsigned int cmd)
{
long err;
struct super_block *sb;
struct au_sbinfo *sbinfo;

err = -EACCES;
if (!capable(CAP_SYS_ADMIN))
goto out;

err = 0;
sb = file->f_dentry->d_sb;
sbinfo = au_sbi(sb);
switch (cmd) {
case AUFS_CTL_PLINK_MAINT:
/*
Expand All @@ -440,7 +438,7 @@ long au_plink_ioctl(struct file *file, unsigned int cmd)
break;
case AUFS_CTL_PLINK_CLEAN:
aufs_write_lock(sb->s_root);
if (au_opt_test(sbinfo->si_mntflags, PLINK))
if (au_opt_test(au_mntflags(sb), PLINK))
au_plink_put(sb);
aufs_write_unlock(sb->s_root);
break;
Expand Down
1 change: 1 addition & 0 deletions fs/aufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
static const struct super_operations aufs_sop = {
.alloc_inode = aufs_alloc_inode,
.destroy_inode = aufs_destroy_inode,
/* always deleting, no clearing */
.drop_inode = generic_delete_inode,
.show_options = aufs_show_options,
.statfs = aufs_statfs,
Expand Down
7 changes: 4 additions & 3 deletions fs/aufs/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@ void au_export_init(struct super_block *sb);

static inline int au_test_nfsd(struct task_struct *tsk)
{
return !tsk->mm && !strcmp(tsk->comm, "nfsd");
return (current->flags & PF_KTHREAD)
&& !strcmp(tsk->comm, "nfsd");
}

int au_xigen_inc(struct inode *inode);
void au_xigen_inc(struct inode *inode);
int au_xigen_new(struct inode *inode);
int au_xigen_set(struct super_block *sb, struct file *base);
void au_xigen_clr(struct super_block *sb);
Expand All @@ -248,7 +249,7 @@ static inline int au_busy_or_stale(void)
#else
AuStubVoid(au_export_init, struct super_block *sb)
AuStubInt0(au_test_nfsd, struct task_struct *tsk)
AuStubInt0(au_xigen_inc, struct inode *inode)
AuStubVoid(au_xigen_inc, struct inode *inode)
AuStubInt0(au_xigen_new, struct inode *inode)
AuStubInt0(au_xigen_set, struct super_block *sb, struct file *base)
AuStubVoid(au_xigen_clr, struct super_block *sb)
Expand Down
2 changes: 1 addition & 1 deletion fs/aufs/wkq.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void au_wkq_fin(void);

static inline int au_test_wkq(struct task_struct *tsk)
{
return !tsk->mm
return (current->flags & PF_KTHREAD)
&& !strncmp(tsk->comm, AUFS_WKQ_NAME "/",
sizeof(AUFS_WKQ_NAME));
}
Expand Down
Loading

0 comments on commit bb3338d

Please sign in to comment.