Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AUFS support / s_files (for Docker AUFS storage driver support) #218

Merged
merged 2 commits into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions fs/aufs/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,23 +568,25 @@ static unsigned long long au_farray_cb(void *a,
{
unsigned long long n;
struct file **p, *f;
struct au_sphlhead *files;
struct au_finfo *finfo;
struct super_block *sb = arg;

n = 0;
p = a;
lg_global_lock(&files_lglock);
do_file_list_for_each_entry(sb, f) {
if (au_fi(f)
&& file_count(f)
files = &au_sbi(sb)->si_files;
spin_lock(&files->spin);
hlist_for_each_entry(finfo, &files->head, fi_hlist) {
f = finfo->fi_file;
if (file_count(f)
&& !special_file(file_inode(f)->i_mode)) {
get_file(f);
*p++ = f;
n++;
AuDebugOn(n > max);
}
} while_file_list_for_each_entry;
lg_global_unlock(&files_lglock);

}
spin_unlock(&files->spin);
return n;
}

Expand Down Expand Up @@ -1273,7 +1275,13 @@ static int au_br_mod_files_ro(struct super_block *sb, aufs_bindex_t bindex)
continue;

/* todo: already flushed? */
/* cf. fs/super.c:mark_files_ro() */
/*
* fs/super.c:mark_files_ro() is gone, but aufs keeps its
* approach which resets f_mode and calls mnt_drop_write() and
* file_release_write() for each file, because the branch
* attribute in aufs world is totally different from the native
* fs rw/ro mode.
*/
/* fi_read_lock(file); */
hfile = &au_fi(file)->fi_htop;
hf = hfile->hf_file;
Expand Down
3 changes: 3 additions & 0 deletions fs/aufs/f_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ int au_do_open_nondir(struct file *file, int flags)
au_set_fbstart(file, bindex);
au_set_h_fptr(file, bindex, h_file);
au_update_figen(file);
finfo->fi_file = file;
au_sphl_add(&finfo->fi_hlist, &au_sbi(dentry->d_sb)->si_files);
/* todo: necessary? */
/* file->f_ra = h_file->f_ra; */
}
Expand Down Expand Up @@ -65,6 +67,7 @@ int aufs_release_nondir(struct inode *inode __maybe_unused, struct file *file)
aufs_bindex_t bindex;

finfo = au_fi(file);
au_sphl_del(&finfo->fi_hlist, &au_sbi(file->f_dentry->d_sb)->si_files);
bindex = finfo->fi_btop;
if (bindex >= 0)
au_set_h_fptr(file, bindex, NULL);
Expand Down
2 changes: 2 additions & 0 deletions fs/aufs/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct au_finfo {
atomic_t fi_mmapped;
};
struct au_fidir *fi_hdir; /* for dir only */
struct hlist_node fi_hlist;
struct file *fi_file; /* very ugly */
} ____cacheline_aligned_in_smp;

/* ---------------------------------------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions fs/aufs/sbinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ int au_si_alloc(struct super_block *sb)
init_waitqueue_head(&sbinfo->si_plink_wq);
spin_lock_init(&sbinfo->si_plink_maint_lock);

au_sphl_init(&sbinfo->si_files);

/* leave other members for sysaufs and si_mnt. */
sbinfo->si_sb = sb;
sb->s_fs_info = sbinfo;
Expand Down
6 changes: 5 additions & 1 deletion fs/aufs/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ struct au_sbinfo {
} au_si_pid;

/*
* dirty approach to protect sb->sb_inodes and ->s_files from remount.
* dirty approach to protect sb->sb_inodes and ->s_files (gone) from
* remount.
*/
atomic_long_t si_ninodes, si_nfiles;

Expand Down Expand Up @@ -177,6 +178,9 @@ struct au_sbinfo {
spinlock_t si_plink_maint_lock;
pid_t si_plink_maint_pid;

/* file list */
struct au_sphlhead si_files;

/*
* sysfs and lifetime management.
* this is not a small structure and it may be a waste of memory in case
Expand Down
13 changes: 8 additions & 5 deletions fs/aufs/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ static void sysrq_sb(struct super_block *sb)
char *plevel;
struct au_sbinfo *sbinfo;
struct file *file;
struct au_sphlhead *files;
struct au_finfo *finfo;

plevel = au_plevel;
au_plevel = KERN_WARNING;
Expand Down Expand Up @@ -73,15 +75,16 @@ static void sysrq_sb(struct super_block *sb)
}
#endif
pr("files\n");
lg_global_lock(&files_lglock);
do_file_list_for_each_entry(sb, file) {
files = &au_sbi(sb)->si_files;
spin_lock(&files->spin);
hlist_for_each_entry(finfo, &files->head, fi_hlist) {
umode_t mode;

file = finfo->fi_file;
mode = file_inode(file)->i_mode;
if (!special_file(mode))
au_dpri_file(file);
} while_file_list_for_each_entry;
lg_global_unlock(&files_lglock);
}
spin_unlock(&files->spin);
pr("done\n");

#undef pr
Expand Down
31 changes: 0 additions & 31 deletions fs/aufs/vfsub.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,6 @@ extern struct lglock vfsmount_lock;
extern void __mnt_drop_write(struct vfsmount *);
extern spinlock_t inode_sb_list_lock;

/* copied from linux/fs/file_table.c */
extern struct lglock files_lglock;
#ifdef CONFIG_SMP
/*
* These macros iterate all files on all CPUs for a given superblock.
* files_lglock must be held globally.
*/
#define do_file_list_for_each_entry(__sb, __file) \
{ \
int i; \
for_each_possible_cpu(i) { \
struct list_head *list; \
list = per_cpu_ptr((__sb)->s_files, i); \
list_for_each_entry((__file), list, f_u.fu_list)

#define while_file_list_for_each_entry \
} \
}

#else

#define do_file_list_for_each_entry(__sb, __file) \
{ \
struct list_head *list; \
list = &(sb)->s_files; \
list_for_each_entry((__file), list, f_u.fu_list)

#define while_file_list_for_each_entry \
}
#endif

/* ---------------------------------------------------------------------- */

/* lock subclass for lower inode */
Expand Down