From: Christoph Hellwig <hch@infradead.org>
To: Chris Mason <mason@suse.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lockfs patch for 2.6
Date: Fri, 12 Mar 2004 09:31:46 +0000 [thread overview]
Message-ID: <20040312093146.A13678@infradead.org> (raw)
In-Reply-To: <1078867885.25075.1458.camel@watt.suse.com>; from mason@suse.com on Tue, Mar 09, 2004 at 04:31:25PM -0500
On Tue, Mar 09, 2004 at 04:31:25PM -0500, Chris Mason wrote:
> /*
> + * triggered by the device mapper code to lock a filesystem and force
> + * it into a consistent state.
> + *
> + * This takes the block device bd_mount_sem to make sure no new mounts
> + * happen on bdev until unlockfs is called. If a super is found on this
> + * block device, we hould a read lock on the s->s_umount sem to make sure
> + * nobody unmounts until the snapshot creation is done
> + */
> +void sync_super_lockfs(struct block_device *bdev)
> +{
> + struct super_block *sb;
> + down(&bdev->bd_mount_sem);
> + sb = get_super(bdev);
> + if (sb) {
> + lock_super(sb);
> + if (sb->s_dirt && sb->s_op->write_super)
> + sb->s_op->write_super(sb);
> + if (sb->s_op->write_super_lockfs)
> + sb->s_op->write_super_lockfs(sb);
Can we please rename write_super_lockfs to a sane name?
freeze_fs/thaw_fs sounds like a good name.
> +void unlockfs(struct block_device *bdev)
> +{
> + struct list_head *p;
> + /*
> + * copied from get_super, but we need to
> + * do special things since lockfs left the
> + * s_umount sem held
> + */
> + spin_lock(&sb_lock);
> + list_for_each(p, &super_blocks) {
> + struct super_block *s = sb_entry(p);
> + /*
> + * if there is a super for this block device
> + * in the list, get_super must have found it
> + * during sync_super_lockfs, so our drop_super
> + * will drop the reference created there.
> + */
> + if (s->s_bdev == bdev && s->s_root) {
> + spin_unlock(&sb_lock);
> + if (s->s_op->unlockfs)
> + s->s_op->unlockfs(s);
> + drop_super(s);
> + goto unlock;
> + }
> + }
> + spin_unlock(&sb_lock);
> +unlock:
> + up(&bdev->bd_mount_sem);
> +}
> +EXPORT_SYMBOL(unlockfs);
This looks ugly. What about returning the superblock from the freeze
routine so you can simply pass it into the thaw routine?
> ===================================================================
> --- linux.dm.orig/fs/buffer.c 2004-02-27 15:47:36.139106189 -0500
> +++ linux.dm/fs/buffer.c 2004-02-27 15:48:41.516739161 -0500
> @@ -260,6 +260,17 @@
> return sync_blockdev(bdev);
> }
>
> +int fsync_bdev_lockfs(struct block_device *bdev)
> +{
> + int res;
> + res = fsync_bdev(bdev);
> + if (res)
> + return res;
> + sync_super_lockfs(bdev);
> + return sync_blockdev(bdev);
> +}
> +EXPORT_SYMBOL(fsync_bdev_lockfs);
This looks grossly misnamed again. And why do you need to have
sync_super_locks splitted out? Calling it on it's own doesn't make much
sense.
> --- linux.dm.orig/include/linux/buffer_head.h 2004-02-05 16:56:30.000000000 -0500
> +++ linux.dm/include/linux/buffer_head.h 2004-02-27 15:48:41.530734995 -0500
> @@ -164,6 +164,8 @@
> wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
> void wake_up_buffer(struct buffer_head *bh);
> int fsync_bdev(struct block_device *);
> +int fsync_bdev_lockfs(struct block_device *);
> +void unlockfs(struct block_device *);
Again rather misplaced. Even a fs not using bufferheads at all would
benefit from the interface.
next prev parent reply other threads:[~2004-03-12 9:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-09 21:31 [PATCH] lockfs patch for 2.6 Chris Mason
2004-03-12 9:31 ` Christoph Hellwig [this message]
2004-03-12 15:50 ` Chris Mason
2004-03-12 15:51 ` Christoph Hellwig
2004-03-13 13:14 ` Christoph Hellwig
2004-03-13 15:20 ` Chris Mason
2004-03-13 16:33 ` Christoph Hellwig
2004-03-14 14:00 ` Christoph Hellwig
2004-03-14 15:23 ` Chris Mason
2004-03-26 10:25 ` Christoph Hellwig
2004-03-26 13:28 ` Chris Mason
2004-04-01 20:35 ` Chris Mason
2004-04-01 22:32 ` Kevin Corry
2004-04-02 20:00 ` Kevin Corry
2004-04-02 20:02 ` Christoph Hellwig
2004-04-02 20:26 ` Kevin Corry
2004-03-14 18:44 ` Andrew Morton
2004-03-14 18:52 ` Christoph Hellwig
2004-03-14 18:56 ` Chris Mason
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=20040312093146.A13678@infradead.org \
--to=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@suse.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).