cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] GFS2: Don't call file_accessed() with a shared glock
Date: Tue, 06 Nov 2012 09:25:18 +0000	[thread overview]
Message-ID: <1352193918.2712.0.camel@menhir> (raw)
In-Reply-To: <20121106064928.GN5182@ether.msp.redhat.com>

Hi,

Looks good. Pushed to the -nmw tree. Thanks,

Steve.

On Tue, 2012-11-06 at 00:49 -0600, Benjamin Marzinski wrote:
> file_accessed() was being called by gfs2_mmap() with a shared glock. If it
> needed to update the atime, it was crashing because it dirtied the inode in
> gfs2_dirty_inode() without holding an exclusive lock. gfs2_dirty_inode()
> checked if the caller was already holding a glock, but it didn't make sure that
> the glock was in the exclusive state. Now, instead of calling file_accessed()
> while holding the shared lock in gfs2_mmap(), file_accessed() is called after
> grabbing and releasing the glock to update the inode.  If file_accessed() needs
> to update the atime, it will grab an exclusive lock in gfs2_dirty_inode().
> 
> gfs2_dirty_inode() now also checks to make sure that if the calling process has
> already locked the glock, it has an exclusive lock.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  fs/gfs2/file.c  |   12 +++++-------
>  fs/gfs2/super.c |    3 ++-
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> Index: gfs2-3.0-nmw/fs/gfs2/file.c
> ===================================================================
> --- gfs2-3.0-nmw.orig/fs/gfs2/file.c
> +++ gfs2-3.0-nmw/fs/gfs2/file.c
> @@ -516,15 +516,13 @@ static int gfs2_mmap(struct file *file,
>  		struct gfs2_holder i_gh;
>  		int error;
>  
> -		gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
> -		error = gfs2_glock_nq(&i_gh);
> -		if (error == 0) {
> -			file_accessed(file);
> -			gfs2_glock_dq(&i_gh);
> -		}
> -		gfs2_holder_uninit(&i_gh);
> +		error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
> +					   &i_gh);
>  		if (error)
>  			return error;
> +		/* grab lock to update inode */
> +		gfs2_glock_dq_uninit(&i_gh);
> +		file_accessed(file);
>  	}
>  	vma->vm_ops = &gfs2_vm_ops;
>  
> Index: gfs2-3.0-nmw/fs/gfs2/super.c
> ===================================================================
> --- gfs2-3.0-nmw.orig/fs/gfs2/super.c
> +++ gfs2-3.0-nmw/fs/gfs2/super.c
> @@ -810,7 +810,8 @@ static void gfs2_dirty_inode(struct inod
>  			return;
>  		}
>  		need_unlock = 1;
> -	}
> +	} else if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE))
> +		return;
>  
>  	if (current->journal_info == NULL) {
>  		ret = gfs2_trans_begin(sdp, RES_DINODE, 0);
> 




      reply	other threads:[~2012-11-06  9:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06  6:49 [Cluster-devel] [PATCH] GFS2: Don't call file_accessed() with a shared glock Benjamin Marzinski
2012-11-06  9:25 ` Steven Whitehouse [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352193918.2712.0.camel@menhir \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).