Hi J.R.

thx for the hint I give it another shot. Linux 3.10 seems to be a little
different. Lets see if my additional patch does its magic:

https://raw.githubusercontent.com/manjaro/packages-core/master/linux310/aufs310-3.10.83-2.patch

On 04.07.2015 11:13, sf...@users.sourceforge.net wrote:
> Hi Philip,
> 
> Philip M ller:
>> With 3.10.83 now it was decided to get rid of s_files and files_lock:
>>
>> http://git.kernel.org/cgit/linux/kernel/git/stable/stable-queue.git/tree/re=
>> leases/3.10.83/get-rid-of-s_files-and-files_lock.patch
>       :::
>> So before I dig into aufs3.10 code and other branches of aufs, I wanted
>> to ask if there is a simple way to solve this. As I already plan to stop
>> supporting linux310 from my end, it might be also a good wink to do so
>> already. That series gets EOL this September anyway ...
> 
> I hope this commit from aufs3-linux.git will help you.
> 
> commit c4f445827ded3d71590e411f7e80b4af73b3483b
> Author: J. R. Okajima <hooano...@yahoo.co.jp>
> Date:   Fri Dec 13 15:51:49 2013 +0900
> 
>     aufs: for linux-3.13, s_files is gone and si_files has come
>     
>     By the commit,
>     eee5cc2 2013-11-09 get rid of s_files and files_lock
>     the file list in superblock, s_files is totally removed.
>     
>     But aufs still needs the file list, particularly for re-setting the
>     branch attribute from RW to RO.
>     After resetting to RO, aufs should return EROFS for write. In order to
>     support such case, aufs keeps the late s_files and mark_files_ro()
>     approach.
>     
>     Signed-off-by: J. R. Okajima <hooano...@yahoo.co.jp>
> 
> diff --git a/fs/aufs/branch.c b/fs/aufs/branch.c
> index e0f8013..196ae1a 100644
> --- a/fs/aufs/branch.c
> +++ b/fs/aufs/branch.c
> @@ -1004,22 +1004,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;
>  }
> @@ -1105,7 +1108,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;
> diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
> index 58944dc..70aec1d 100644
> --- a/fs/aufs/f_op.c
> +++ b/fs/aufs/f_op.c
> @@ -52,11 +52,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);
> -             if (!(file->f_mode & FMODE_WRITE)) {
> -                     lg_local_lock(&files_lglock);
> -                     __file_sb_list_add(file, dentry->d_sb);
> -                     lg_local_unlock(&files_lglock);
> -             }
> +             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; */
>       }
> @@ -88,6 +85,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);
> diff --git a/fs/aufs/file.h b/fs/aufs/file.h
> index f5d63ad..2c28527 100644
> --- a/fs/aufs/file.h
> +++ b/fs/aufs/file.h
> @@ -62,6 +62,9 @@ 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;
>  
>  /* ---------------------------------------------------------------------- */
> diff --git a/fs/aufs/sbinfo.c b/fs/aufs/sbinfo.c
> index 5e8713a..c675fa1 100644
> --- a/fs/aufs/sbinfo.c
> +++ b/fs/aufs/sbinfo.c
> @@ -117,6 +117,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;
> diff --git a/fs/aufs/super.h b/fs/aufs/super.h
> index 051458d..b984ad1 100644
> --- a/fs/aufs/super.h
> +++ b/fs/aufs/super.h
> @@ -95,7 +95,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;
>  
> @@ -173,6 +174,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
> diff --git a/fs/aufs/sysrq.c b/fs/aufs/sysrq.c
> index 4d770ad..f214bcd 100644
> --- a/fs/aufs/sysrq.c
> +++ b/fs/aufs/sysrq.c
> @@ -31,6 +31,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;
> @@ -86,14 +88,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_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
> diff --git a/fs/aufs/vfsub.h b/fs/aufs/vfsub.h
> index 08d3622..42a617f 100644
> --- a/fs/aufs/vfsub.h
> +++ b/fs/aufs/vfsub.h
> @@ -34,38 +34,6 @@
>  /* todo: BAD approach!! */
>  extern void __mnt_drop_write(struct vfsmount *);
>  extern spinlock_t inode_sb_list_lock;
> -void __file_sb_list_add(struct file *file, struct super_block *sb);
> -
> -/* 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
>  
>  /* ---------------------------------------------------------------------- */
>  
> 


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/

Reply via email to