public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block_dev.c: fsync() on close() considered harmful
@ 2001-11-22 13:34 Miquel van Smoorenburg
  2001-11-22 17:26 ` Andrea Arcangeli
  0 siblings, 1 reply; 4+ messages in thread
From: Miquel van Smoorenburg @ 2001-11-22 13:34 UTC (permalink / raw)
  To: Andrea Arcangeli; +Cc: linux-kernel

I'm running an INN usenet news server that uses raw partitions for
storage. I.e. it opens /dev/sda7 etc. and mmap()s [which finally
works in 2.4, hurray]

Even though the server is keeping those devices open, when a utility
program (sm) opens that file/device and closes() it the close() causes
a fsync() on the device, something that is not wanted.

I applied the following patch which fixes it for me, it prevents
the sync-after-close if it was close() calling blkdev_put()
and we're not the last one to call blkdev_put().

That means fsync() will still be done on unmounts or when the
last user of the device closes it, but not otherwise.

Is this correct or am I overlooking something?

--- linux-2.4.15-pre8/fs/block_dev.c.orig	Thu Oct 25 22:58:35 2001
+++ linux-2.4.15-pre8/fs/block_dev.c	Wed Nov 21 13:32:16 2001
@@ -603,7 +603,7 @@
 
	down(&bdev->bd_sem);
	lock_kernel();
-	if (kind == BDEV_FILE)
+	if (kind == BDEV_FILE && bdev->bd_openers == 1)
		__block_fsync(bd_inode);
	else if (kind == BDEV_FS)
		fsync_no_super(rdev);


Mike.
-- 
"Only two things are infinite, the universe and human stupidity,
 and I'm not sure about the former" -- Albert Einstein.

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH] block_dev.c: fsync() on close() considered harmful
@ 2002-02-25 18:04 Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2002-02-25 18:04 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

Hi Alan,

I don't see any standard specifying that fsync should be done on
every blockdevice close.

Any chance you could add the below patch to the next -ac release?

	Christoph


Date: Thu, 22 Nov 2001 14:34:50 +0100
From: Miquel van Smoorenburg <miquels@cistron.nl>
To: Andrea Arcangeli <andrea@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] block_dev.c: fsync() on close() considered harmful
Message-ID: <20011122143450.A28020@cistron.nl>
Reply-To: linux-kernel@vger.kernel.org
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
X-NCC-RegID: nl.cistron

I'm running an INN usenet news server that uses raw partitions for
storage. I.e. it opens /dev/sda7 etc. and mmap()s [which finally
works in 2.4, hurray]

Even though the server is keeping those devices open, when a utility
program (sm) opens that file/device and closes() it the close() causes
a fsync() on the device, something that is not wanted.

I applied the following patch which fixes it for me, it prevents
the sync-after-close if it was close() calling blkdev_put()
and we're not the last one to call blkdev_put().

That means fsync() will still be done on unmounts or when the
last user of the device closes it, but not otherwise.

Is this correct or am I overlooking something?

--- linux-2.4.15-pre8/fs/block_dev.c.orig	Thu Oct 25 22:58:35 2001
+++ linux-2.4.15-pre8/fs/block_dev.c	Wed Nov 21 13:32:16 2001
@@ -603,7 +603,7 @@
 
	down(&bdev->bd_sem);
	lock_kernel();
-	if (kind == BDEV_FILE)
+	if (kind == BDEV_FILE && bdev->bd_openers == 1)
		__block_fsync(bd_inode);
	else if (kind == BDEV_FS)
		fsync_no_super(rdev);


Mike.
-- 
"Only two things are infinite, the universe and human stupidity,
 and I'm not sure about the former" -- Albert Einstein.


^ permalink raw reply	[flat|nested] 4+ messages in thread
* RE: [PATCH] block_dev.c: fsync() on close() considered harmful
@ 2002-02-25 22:36 Christine Ames
  0 siblings, 0 replies; 4+ messages in thread
From: Christine Ames @ 2002-02-25 22:36 UTC (permalink / raw)
  To: post linux-kernel

Christoph Hellwig [hch@caldera.de] wrote:
> Hi Alan,
> 
> I don't see any standard specifying that fsync should be done on
> every blockdevice close.
> 
> Any chance you could add the below patch to the next -ac release?
> 
> 	Christoph

I am writing a partitionable block device driver for the 2.4 kernel.
Once the driver is loaded and the device mounted, reading, writing,
and ioctls work properly.

The driver becomes unstable after many mounts/unmounts, and I have
come to suspect that I am not calling fsync_dev() correctly.

I do call fsync_dev() on release as well as on remove.
Is this incorrect?  Can it lead to instability?  I've counted four
different ways in which the driver dies, including a call to 
BUG() in buffer.c...

Thank you,

Christine


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-02-25 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-22 13:34 [PATCH] block_dev.c: fsync() on close() considered harmful Miquel van Smoorenburg
2001-11-22 17:26 ` Andrea Arcangeli
  -- strict thread matches above, loose matches on Subject: below --
2002-02-25 18:04 Christoph Hellwig
2002-02-25 22:36 Christine Ames

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox