LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Vladimir V. Saveliev" <vs@namesys.com>
To: Adrian Bunk <bunk@stusta.de>
Cc: reiserfs-dev@namesys.com,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: How many people are using 2.6.16?
Date: Thu, 1 Feb 2007 15:13:03 +0300	[thread overview]
Message-ID: <200702011513.04627.vs@namesys.com> (raw)
In-Reply-To: <20070131070237.GT3754@stusta.de>

Hello

On Wednesday 31 January 2007 10:02, Adrian Bunk wrote:
> On Tue, Jan 30, 2007 at 06:36:48PM -0800, Linus Torvalds wrote:
> > 
> > 
> > On Tue, 30 Jan 2007, Mark Lord wrote:
> > > 
> > > I believe our featherless leader said he though it was an ancient bug,
> > > exasperated by something that went into 2.6.19.
> > > 
> > > If Linus's opinion is correct (still?), then the bug exists in all
> > > kernels since somewhere back in the 2.4.xx days.
> > 
> > The issue was somewhat confused by people certainly *reporting* it for 
> > older kernels. Also, as part of the dirty bit cleanups and sanity 
> > checkingwe did actually seem to fix a long-standing CIFS corruption (and 
> > apparently reisertfs/XFS problems too).
> > 
> > But the *common* case was actually introduced with 2.6.19, and 2.6.16 
> > wouldn't be affected. 
> 
> Thanks for the clarifications.
> 
> Regarding the longstanding CIFS/reiserfs/XFS problems, it seems the 
> status is:
> 
> CIFS:
> commit cb876f451455b6187a7d69de2c112c45ec4b7f99
>   Fix up CIFS for "test_clear_page_dirty()" removal
> queued for 2.6.19.3
> applies and compiles against 2.6.16
> 
> reiserfs:
> commit de14569f94513279e3d44d9571a421e9da1759ae
>   [PATCH] resierfs: avoid tail packing if an inode was ever mmapped
> backport to 2.6.16 required
> 

Here it goes:

From: akpm@osdl.org

The patch titled
     resierfs: avoid tail packing if an inode was ever mmapped
has been added to the -mm tree.  Its filename is
     reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: resierfs: avoid tail packing if an inode was ever mmapped
From: Vladimir Saveliev <vs@namesys.com>

This patch fixes a confusion reiserfs has for a long time.

On release file operation reiserfs used to try to pack file data stored in
last incomplete page of some files into metadata blocks.  After packing the
page got cleared with clear_page_dirty.  It did not take into account that
the page may be mmaped into other process's address space.  Recent
replacement for clear_page_dirty cancel_dirty_page found the confusion with
sanity check that page has to be not mapped.

The patch fixes the confusion by making reiserfs avoid tail packing if an
inode was ever mmapped.  reiserfs_mmap and reiserfs_file_release are
serialized with mutex in reiserfs specific inode.  reiserfs_mmap locks the
mutex and sets a bit in reiserfs specific inode flags. 
reiserfs_file_release checks the bit having the mutex locked.  If bit is
set - tail packing is avoided.  This eliminates a possibility that mmapped
page gets cancel_page_dirty-ed.

Signed-off-by: Vladimir Saveliev <vs@namesys.com>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Chris Mason <mason@suse.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

diff -puN fs/reiserfs/file.c~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped fs/reiserfs/file.c



diff -puN fs/reiserfs/file.c~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped fs/reiserfs/file.c
--- linux-2.6.16/fs/reiserfs/file.c~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped	2007-02-01 12:30:08.000000000 +0300
+++ linux-2.6.16-vs/fs/reiserfs/file.c	2007-02-01 12:43:07.000000000 +0300
@@ -50,6 +50,11 @@ static int reiserfs_file_release(struct 
 
 	reiserfs_write_lock(inode->i_sb);
 	mutex_lock(&inode->i_mutex);
+ 
+ 	mutex_lock(&(REISERFS_I(inode)->i_mmap));
+ 	if (REISERFS_I(inode)->i_flags & i_ever_mapped)
+ 		REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
+ 
 	/* freeing preallocation only involves relogging blocks that
 	 * are already in the current transaction.  preallocation gets
 	 * freed at the end of each transaction, so it is impossible for
@@ -100,11 +105,24 @@ static int reiserfs_file_release(struct 
 		err = reiserfs_truncate_file(inode, 0);
 	}
       out:
+	mutex_unlock(&(REISERFS_I(inode)->i_mmap));
 	mutex_unlock(&inode->i_mutex);
 	reiserfs_write_unlock(inode->i_sb);
 	return err;
 }
 
+static int reiserfs_file_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	struct inode *inode;
+
+	inode = file->f_dentry->d_inode;
+	mutex_lock(&(REISERFS_I(inode)->i_mmap));
+	REISERFS_I(inode)->i_flags |= i_ever_mapped;
+	mutex_unlock(&(REISERFS_I(inode)->i_mmap));
+
+	return generic_file_mmap(file, vma);
+}
+
 static void reiserfs_vfs_truncate_file(struct inode *inode)
 {
 	reiserfs_truncate_file(inode, 1);
@@ -1570,7 +1588,7 @@ struct file_operations reiserfs_file_ope
 	.read = generic_file_read,
 	.write = reiserfs_file_write,
 	.ioctl = reiserfs_ioctl,
-	.mmap = generic_file_mmap,
+	.mmap = reiserfs_file_mmap,
 	.release = reiserfs_file_release,
 	.fsync = reiserfs_sync_file,
 	.sendfile = generic_file_sendfile,
diff -puN fs/reiserfs/inode.c~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped fs/reiserfs/inode.c
--- linux-2.6.16/fs/reiserfs/inode.c~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped	2007-02-01 12:30:08.000000000 +0300
+++ linux-2.6.16-vs/fs/reiserfs/inode.c	2007-02-01 12:41:32.000000000 +0300
@@ -1140,6 +1140,7 @@ static void init_inode(struct inode *ino
 	REISERFS_I(inode)->i_prealloc_count = 0;
 	REISERFS_I(inode)->i_trans_id = 0;
 	REISERFS_I(inode)->i_jl = NULL;
+	mutex_init(&(REISERFS_I(inode)->i_mmap));
 	REISERFS_I(inode)->i_acl_access = NULL;
 	REISERFS_I(inode)->i_acl_default = NULL;
 	init_rwsem(&REISERFS_I(inode)->xattr_sem);
@@ -1847,6 +1848,7 @@ int reiserfs_new_inode(struct reiserfs_t
 	REISERFS_I(inode)->i_attrs =
 	    REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK;
 	sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode);
+	mutex_init(&(REISERFS_I(inode)->i_mmap));
 	REISERFS_I(inode)->i_acl_access = NULL;
 	REISERFS_I(inode)->i_acl_default = NULL;
 	init_rwsem(&REISERFS_I(inode)->xattr_sem);
diff -puN include/linux/reiserfs_fs_i.h~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped include/linux/reiserfs_fs_i.h
--- linux-2.6.16/include/linux/reiserfs_fs_i.h~reiserfs-avoid-tail-packing-if-an-inode-was-ever-mmapped	2007-02-01 12:30:08.000000000 +0300
+++ linux-2.6.16-vs/include/linux/reiserfs_fs_i.h	2007-02-01 12:35:50.000000000 +0300
@@ -25,6 +25,7 @@ typedef enum {
 	i_link_saved_truncate_mask = 0x0020,
 	i_has_xattr_dir = 0x0040,
 	i_data_log = 0x0080,
+	i_ever_mapped = 0x0100
 } reiserfs_inode_flags;
 
 struct reiserfs_inode_info {
@@ -52,6 +53,7 @@ struct reiserfs_inode_info {
 	 ** flushed */
 	unsigned long i_trans_id;
 	struct reiserfs_journal_list *i_jl;
+	struct mutex i_mmap;
 
 	struct posix_acl *i_acl_access;
 	struct posix_acl *i_acl_default;

_



  parent reply	other threads:[~2007-02-01 11:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-29 20:30 Chuck Ebbert
2007-01-29 20:35 ` Josh Boyer
2007-01-29 20:38   ` Chuck Ebbert
2007-02-07 20:36     ` Greg KH
2007-01-29 21:04 ` Mike Houston
2007-01-29 22:13   ` Bron Gondwana
2007-01-30 20:39     ` Adrian Bunk
2007-01-31  1:33       ` Mark Lord
2007-01-31  2:36         ` Linus Torvalds
2007-01-31  5:49           ` Bron Gondwana
2007-01-31  7:02           ` Adrian Bunk
2007-01-31 10:42             ` Reiserfs and MMAP (was: How many people are using 2.6.16?) Bron Gondwana
2007-01-31 11:49             ` How many people are using 2.6.16? David Chinner
2007-01-31 14:34               ` Steve French (smfltc)
2007-01-31 15:34             ` Linus Torvalds
2007-02-01 12:13             ` Vladimir V. Saveliev [this message]
2007-02-03  1:39               ` Adrian Bunk
2007-01-30 23:52   ` Adrian Bunk
2007-01-31  1:48     ` Mike Houston

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=200702011513.04627.vs@namesys.com \
    --to=vs@namesys.com \
    --cc=bunk@stusta.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-dev@namesys.com \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: How many people are using 2.6.16?' \
    /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

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).