From: "Fernando Luis Vázquez Cao" <fernando_b1@lab.ntt.co.jp>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Josef Bacik <jbacik@fusionio.com>,
Eric Sandeen <sandeen@redhat.com>,
Dave Chinner <dchinner@redhat.com>,
Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 9/9] fsfreeze: add block device ioctl to check freeze state
Date: Thu, 13 Sep 2012 20:13:13 +0900 [thread overview]
Message-ID: <1347534793.5646.19.camel@nexus.lab.ntt.co.jp> (raw)
In-Reply-To: <1347533862.5646.2.camel@nexus.lab.ntt.co.jp>
The BLKISFROZEN ioctl can be used to check the freeze state of a block device
(it is possible to freeze a block device that does not have a filesystem
sitting on top of it).
If allowing the umounting of frozen filesystems is deemed acceptable this ioctl
will be extended to check the state of the associated superblock if any.
Cc: Josef Bacik <jbacik@fusionio.com>
Cc: Eric Sandeen <sandeen@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
---
diff -urNp linux-3.6-rc5-orig/block/compat_ioctl.c linux-3.6-rc5/block/compat_ioctl.c
--- linux-3.6-rc5-orig/block/compat_ioctl.c 2012-07-22 05:58:29.000000000 +0900
+++ linux-3.6-rc5/block/compat_ioctl.c 2012-09-13 16:22:16.092304889 +0900
@@ -746,6 +746,13 @@ long compat_blkdev_ioctl(struct file *fi
case BLKTRACETEARDOWN: /* compatible */
ret = blk_trace_ioctl(bdev, cmd, compat_ptr(arg));
return ret;
+ case BLKISFROZEN:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ ret = isfrozen_bdev(bdev);
+ if (ret >= 0)
+ return compat_put_int(arg, ret);
+ return ret;
default:
if (disk->fops->compat_ioctl)
ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
diff -urNp linux-3.6-rc5-orig/block/ioctl.c linux-3.6-rc5/block/ioctl.c
--- linux-3.6-rc5-orig/block/ioctl.c 2012-09-12 20:23:55.230047001 +0900
+++ linux-3.6-rc5/block/ioctl.c 2012-09-13 16:22:16.092304889 +0900
@@ -396,6 +396,13 @@ int blkdev_ioctl(struct block_device *bd
case BLKTRACETEARDOWN:
ret = blk_trace_ioctl(bdev, cmd, (char __user *) arg);
break;
+ case BLKISFROZEN:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ ret = isfrozen_bdev(bdev);
+ if (ret >= 0)
+ return put_int(arg, ret);
+ return ret;
default:
ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
}
diff -urNp linux-3.6-rc5-orig/fs/block_dev.c linux-3.6-rc5/fs/block_dev.c
--- linux-3.6-rc5-orig/fs/block_dev.c 2012-09-13 15:38:07.332137396 +0900
+++ linux-3.6-rc5/fs/block_dev.c 2012-09-13 16:22:16.092304889 +0900
@@ -328,6 +328,11 @@ out:
}
EXPORT_SYMBOL(thaw_bdev);
+int isfrozen_bdev(struct block_device *bdev)
+{
+ return bdev->bd_fsfreeze_count > 0;
+}
+
static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
{
return block_write_full_page(page, blkdev_get_block, wbc);
diff -urNp linux-3.6-rc5-orig/include/linux/fs.h linux-3.6-rc5/include/linux/fs.h
--- linux-3.6-rc5-orig/include/linux/fs.h 2012-09-13 16:15:04.996291015 +0900
+++ linux-3.6-rc5/include/linux/fs.h 2012-09-13 16:22:16.092304889 +0900
@@ -335,6 +335,7 @@ struct inodes_stat_t {
#define BLKDISCARDZEROES _IO(0x12,124)
#define BLKSECDISCARD _IO(0x12,125)
#define BLKROTATIONAL _IO(0x12,126)
+#define BLKISFROZEN _IOR(0x12,127, int) /* get file system freeze state */
#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
#define FIBMAP _IO(0x00,1) /* bmap access */
@@ -2251,6 +2252,7 @@ extern void kill_bdev(struct block_devic
extern struct super_block *freeze_bdev(struct block_device *);
extern void emergency_thaw_all(void);
extern int thaw_bdev(struct block_device *bdev, struct super_block *sb);
+extern int isfrozen_bdev(struct block_device *bdev);
extern int fsync_bdev(struct block_device *);
#else
static inline void bd_forget(struct inode *inode) {}
@@ -2271,6 +2273,11 @@ static inline int thaw_bdev(struct block
static inline void iterate_bdevs(void (*f)(struct block_device *, void *), void *arg)
{
}
+
+static int isfrozen_bdev(struct block_device *bdev)
+{
+ return 0;
+}
#endif
extern int sync_filesystem(struct super_block *);
extern const struct file_operations def_blk_fops;
next prev parent reply other threads:[~2012-09-13 11:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-13 10:57 [RFC 0/9 v3] fsfreeze: miscellaneous fixes and cleanups Fernando Luis Vázquez Cao
2012-09-13 11:00 ` [PATCH 1/9] vfs: add __iterate_supers() helper Fernando Luis Vázquez Cao
2012-09-14 2:36 ` Eric Sandeen
2012-09-14 2:40 ` Fernando Luis Vazquez Cao
2012-09-13 11:01 ` [RFC 2/9] fsfreeze: add unlocked version of thaw_super Fernando Luis Vázquez Cao
2012-09-13 18:13 ` Eric Sandeen
2012-09-13 11:03 ` [RFC 3/9] fsfreeze: Prevent emergency thaw from looping infinitely Fernando Luis Vázquez Cao
2012-09-13 16:40 ` Eric Sandeen
2012-09-13 11:04 ` [RFC 4/9] fsfreeze: emergency thaw will deadlock on s_umount Fernando Luis Vázquez Cao
2012-09-13 11:07 ` [RFC 5/9] xfs: switch to using super methods for fsfreeze Fernando Luis Vázquez Cao
2012-09-13 11:08 ` [RFC 6/9] fsfreeze: move emergency thaw code to fs/super.c Fernando Luis Vázquez Cao
2012-09-13 19:00 ` Josef Bacik
2012-09-13 21:10 ` Eric Sandeen
2012-09-14 2:11 ` Fernando Luis Vazquez Cao
2012-09-14 1:59 ` Fernando Luis Vazquez Cao
2012-09-13 11:10 ` [PATCH 7/9] fsfreeze: freeze_super and thaw_bdev don't play well together Fernando Luis Vázquez Cao
2012-09-13 11:11 ` [PATCH 8/9] fsfreeze: add vfs ioctl to check freeze state Fernando Luis Vázquez Cao
2012-09-13 11:13 ` Fernando Luis Vázquez Cao [this message]
2012-09-14 0:57 ` [RFC 0/9 v3] fsfreeze: miscellaneous fixes and cleanups Dave Chinner
2012-09-14 2:20 ` Fernando Luis Vazquez Cao
2012-09-14 2:33 ` Eric Sandeen
2012-09-14 2:48 ` Fernando Luis Vazquez Cao
2012-09-14 6:22 ` Fernando Luis Vazquez Cao
-- strict thread matches above, loose matches on Subject: below --
2012-09-14 6:43 [RFC, PATCH 0/9 v4] " Fernando Luis Vázquez Cao
2012-09-14 6:55 ` [PATCH 9/9] fsfreeze: add block device ioctl to check freeze state Fernando Luis Vázquez Cao
2012-10-05 5:24 [PATCH 0/9 v5] fsfreeze: miscellaneous fixes and cleanups Fernando Luis Vázquez Cao
2012-10-05 5:44 ` [PATCH 9/9] fsfreeze: add block device ioctl to check freeze state Fernando Luis Vázquez Cao
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=1347534793.5646.19.camel@nexus.lab.ntt.co.jp \
--to=fernando_b1@lab.ntt.co.jp \
--cc=dchinner@redhat.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=jbacik@fusionio.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sandeen@redhat.com \
--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).