Re: [PATCH 28/30] r/o bind mounts: track numbers of writers to mounts

2008-02-20 Thread Dave Hansen
On Mon, 2008-02-18 at 17:10 +0100, Miklos Szeredi wrote:
> 
> > + /*
> > +  * We don't have to hold all of the locks at the
> > +  * same time here because we know that we're the
> > +  * last reference to mnt and that no new writers
> > +  * can come in.
> > +  */
> > + for_each_possible_cpu(cpu) {
> > + struct mnt_writer *cpu_writer = _cpu(mnt_writers, cpu);
> > + if (cpu_writer->mnt != mnt)
> > + continue;
> > + spin_lock(_writer->lock);
> > + atomic_add(cpu_writer->count, >__mnt_writers);
> > + cpu_writer->count = 0;
> 
> I think you should also add a
> 
> cpu_writer->mnt = NULL;
> 
> here.  It's not a bug, but I had to think a bit about why it's not a
> bug.

Yeah, I kinda copied the code from __clear_mnt_count() where keeping
->mnt is actually a mini optimization.  But, there is certainly no
chance of that mnt popping up again after a __mntput(), so I clear it in
there now.  I also added a comment explaining.

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 28/30] r/o bind mounts: track numbers of writers to mounts

2008-02-20 Thread Dave Hansen
On Mon, 2008-02-18 at 17:10 +0100, Miklos Szeredi wrote:
 
  + /*
  +  * We don't have to hold all of the locks at the
  +  * same time here because we know that we're the
  +  * last reference to mnt and that no new writers
  +  * can come in.
  +  */
  + for_each_possible_cpu(cpu) {
  + struct mnt_writer *cpu_writer = per_cpu(mnt_writers, cpu);
  + if (cpu_writer-mnt != mnt)
  + continue;
  + spin_lock(cpu_writer-lock);
  + atomic_add(cpu_writer-count, mnt-__mnt_writers);
  + cpu_writer-count = 0;
 
 I think you should also add a
 
 cpu_writer-mnt = NULL;
 
 here.  It's not a bug, but I had to think a bit about why it's not a
 bug.

Yeah, I kinda copied the code from __clear_mnt_count() where keeping
-mnt is actually a mini optimization.  But, there is certainly no
chance of that mnt popping up again after a __mntput(), so I clear it in
there now.  I also added a comment explaining.

-- Dave

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 28/30] r/o bind mounts: track numbers of writers to mounts

2008-02-18 Thread Miklos Szeredi
> @@ -327,7 +514,30 @@ static struct vfsmount *clone_mnt(struct
>  
>  static inline void __mntput(struct vfsmount *mnt)
>  {
> + int cpu;
>   struct super_block *sb = mnt->mnt_sb;
> + /*
> +  * We don't have to hold all of the locks at the
> +  * same time here because we know that we're the
> +  * last reference to mnt and that no new writers
> +  * can come in.
> +  */
> + for_each_possible_cpu(cpu) {
> + struct mnt_writer *cpu_writer = _cpu(mnt_writers, cpu);
> + if (cpu_writer->mnt != mnt)
> + continue;
> + spin_lock(_writer->lock);
> + atomic_add(cpu_writer->count, >__mnt_writers);
> + cpu_writer->count = 0;

I think you should also add a

cpu_writer->mnt = NULL;

here.  It's not a bug, but I had to think a bit about why it's not a bug.

Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 28/30] r/o bind mounts: track numbers of writers to mounts

2008-02-18 Thread Miklos Szeredi
 @@ -327,7 +514,30 @@ static struct vfsmount *clone_mnt(struct
  
  static inline void __mntput(struct vfsmount *mnt)
  {
 + int cpu;
   struct super_block *sb = mnt-mnt_sb;
 + /*
 +  * We don't have to hold all of the locks at the
 +  * same time here because we know that we're the
 +  * last reference to mnt and that no new writers
 +  * can come in.
 +  */
 + for_each_possible_cpu(cpu) {
 + struct mnt_writer *cpu_writer = per_cpu(mnt_writers, cpu);
 + if (cpu_writer-mnt != mnt)
 + continue;
 + spin_lock(cpu_writer-lock);
 + atomic_add(cpu_writer-count, mnt-__mnt_writers);
 + cpu_writer-count = 0;

I think you should also add a

cpu_writer-mnt = NULL;

here.  It's not a bug, but I had to think a bit about why it's not a bug.

Miklos
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/