linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Wu Fengguang <fengguang.wu@intel.com>
Cc: <stable@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
	<linux-fsdevel@vger.kernel.org>
Subject: [PATCH 3/4] vfs: take f_lock on modifying f_mode after open time
Date: Fri, 22 Jan 2010 12:59:17 +0800	[thread overview]
Message-ID: <20100122051517.549075734@intel.com> (raw)
In-Reply-To: 20100122045914.993668874@intel.com

[-- Attachment #1: fmode-lock.patch --]
[-- Type: text/plain, Size: 1165 bytes --]

We'll introduce FMODE_RANDOM which will be runtime modified.
So protect all runtime modification to f_mode with f_lock to
avoid races.

CC: Al Viro <viro@zeniv.linux.org.uk>
CC: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 fs/file_table.c     |    2 ++
 fs/nfsd/nfs4state.c |    2 ++
 2 files changed, 4 insertions(+)

--- linux.orig/fs/file_table.c	2010-01-15 09:11:07.000000000 +0800
+++ linux/fs/file_table.c	2010-01-15 09:11:15.000000000 +0800
@@ -392,7 +392,9 @@ retry:
 			continue;
 		if (!(f->f_mode & FMODE_WRITE))
 			continue;
+		spin_lock(&f->f_lock);
 		f->f_mode &= ~FMODE_WRITE;
+		spin_unlock(&f->f_lock);
 		if (file_check_writeable(f) != 0)
 			continue;
 		file_release_write(f);
--- linux.orig/fs/nfsd/nfs4state.c	2010-01-15 09:08:22.000000000 +0800
+++ linux/fs/nfsd/nfs4state.c	2010-01-15 09:11:15.000000000 +0800
@@ -1998,7 +1998,9 @@ nfs4_file_downgrade(struct file *filp, u
 {
 	if (share_access & NFS4_SHARE_ACCESS_WRITE) {
 		drop_file_write_access(filp);
+		spin_lock(&filp->f_lock);
 		filp->f_mode = (filp->f_mode | FMODE_READ) & ~FMODE_WRITE;
+		spin_unlock(&filp->f_lock);
 	}
 }
 

  parent reply	other threads:[~2010-01-22  4:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22  4:59 [PATCH 0/4] devmem and readahead fixes for 2.6.33 Wu Fengguang
2010-01-22  4:59 ` [PATCH 1/4] devmem: check vmalloc address on kmem read/write Wu Fengguang
2010-01-22  4:59 ` [PATCH 2/4] devmem: fix kmem write bug on memory holes Wu Fengguang
2010-01-22  4:59 ` Wu Fengguang [this message]
2010-01-22  4:59 ` [PATCH 4/4] readahead: introduce FMODE_RANDOM for POSIX_FADV_RANDOM Wu Fengguang
2010-01-22  5:31 ` [PATCH 0/4] devmem and readahead fixes for 2.6.33 Greg KH
2010-01-27  0:50   ` Andrew Morton
2010-01-27  1:39     ` Greg KH
2010-01-27  2:45     ` Wu Fengguang
2010-02-03 23:47 ` [stable] " Greg KH
2010-02-04  2:42   ` [stable] [PATCH] devmem: check vmalloc address on kmem read/write Wu Fengguang
2010-02-04  2:43     ` [stable] [PATCH] devmem: fix kmem write bug on memory holes Wu Fengguang
2010-02-04  2:58     ` [stable] [PATCH] devmem: check vmalloc address on kmem read/write KAMEZAWA Hiroyuki
2010-02-04  3:18       ` Wu Fengguang
2010-02-04  3:27         ` KAMEZAWA Hiroyuki

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=20100122051517.549075734@intel.com \
    --to=fengguang.wu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=hch@infradead.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).