From: "Fernando Luis Vázquez Cao" <fernando@oss.ntt.co.jp>
To: "Fernando Luis Vázquez Cao" <fernando@oss.ntt.co.jp>
Cc: t-sato@yk.jp.nec.com, m-hamaguchi@ys.jp.nec.com,
Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH 4/4] filesystem freeze: add ISFROZEN ioctl
Date: Thu, 27 Aug 2009 23:06:18 +0900 [thread overview]
Message-ID: <4A9692DA.20805@oss.ntt.co.jp> (raw)
In-Reply-To: <4A94C151.8020900@oss.ntt.co.jp>
The ISFROZEN ioctl can be use by HA and monitoring software to check
the freeze state of a filesystem.
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
---
diff -urNp linux-2.6.31-rc7-orig/fs/block_dev.c linux-2.6.31-rc7/fs/block_dev.c
--- linux-2.6.31-rc7-orig/fs/block_dev.c 2009-08-27 14:48:12.000000000 +0900
+++ linux-2.6.31-rc7/fs/block_dev.c 2009-08-27 18:49:46.000000000 +0900
@@ -334,6 +334,21 @@ out_unlock:
}
EXPORT_SYMBOL(thaw_bdev);
+/**
+ *
+ */
+int isfrozen_bdev(struct block_device *bdev, struct super_block *sb)
+{
+ int ret;
+
+ mutex_lock(&bdev->bd_fsfreeze_mutex);
+ ret = sb->s_frozen > SB_UNFROZEN ? 1:0;
+ mutex_unlock(&bdev->bd_fsfreeze_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL(isfrozen_bdev);
+
static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
{
return block_write_full_page(page, blkdev_get_block, wbc);
diff -urNp linux-2.6.31-rc7-orig/fs/ioctl.c linux-2.6.31-rc7/fs/ioctl.c
--- linux-2.6.31-rc7-orig/fs/ioctl.c 2009-08-27 10:08:00.000000000 +0900
+++ linux-2.6.31-rc7/fs/ioctl.c 2009-08-27 18:49:17.000000000 +0900
@@ -536,6 +536,20 @@ static int ioctl_fsthaw(struct file *fil
return thaw_bdev(sb->s_bdev, sb);
}
+static int ioctl_isfrozen(struct file *filp)
+{
+ struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ /* If a blockdevice-backed filesystem isn't specified, return EINVAL. */
+ if (sb->s_bdev == NULL)
+ return -EINVAL;
+
+ return isfrozen_bdev(sb->s_bdev, sb);
+}
+
/*
* When you add any new common ioctls to the switches above and below
* please update compat_sys_ioctl() too.
@@ -586,6 +600,12 @@ int do_vfs_ioctl(struct file *filp, unsi
error = ioctl_fsthaw(filp);
break;
+ case FIISFROZEN:
+ error = ioctl_isfrozen(filp);
+ if (error >= 0)
+ return put_user(error, (int __user *)arg);
+ break;
+
case FS_IOC_FIEMAP:
return ioctl_fiemap(filp, arg);
diff -urNp linux-2.6.31-rc7-orig/include/linux/fs.h linux-2.6.31-rc7/include/linux/fs.h
--- linux-2.6.31-rc7-orig/include/linux/fs.h 2009-08-27 14:48:12.000000000 +0900
+++ linux-2.6.31-rc7/include/linux/fs.h 2009-08-27 16:33:19.000000000 +0900
@@ -306,6 +306,7 @@ struct inodes_stat_t {
#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
#define FITHAW _IOWR('X', 120, int) /* Thaw */
+#define FIISFROZEN _IOWR('X', 121, int) /* Is frozen? */
#define FS_IOC_GETFLAGS _IOR('f', 1, long)
#define FS_IOC_SETFLAGS _IOW('f', 2, long)
@@ -1955,6 +1956,7 @@ extern int sync_blockdev(struct block_de
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, struct super_block *sb);
extern int fsync_bdev(struct block_device *);
#else
static inline void bd_forget(struct inode *inode) {}
@@ -1970,6 +1972,12 @@ static inline int thaw_bdev(struct block
{
return 0;
}
+
+extern int isfrozen_bdev(struct block_device *bdev, struct super_block *sb)
+{
+ return 0;
+}
+
#endif
extern int sync_filesystem(struct super_block *);
extern const struct file_operations def_blk_fops;
prev parent reply other threads:[~2009-08-27 14:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 5:00 [RFC, PATCH] filesystem freeze: fix sys_umount induced perpetual freeze Fernando Luis Vázquez Cao
2009-08-26 17:38 ` Christoph Hellwig
2009-08-27 10:11 ` Fernando Luis Vázquez Cao
2009-08-27 11:54 ` Christoph Hellwig
2009-08-27 12:16 ` Fernando Luis Vázquez Cao
2009-08-27 14:05 ` [PATCH 1/4] freeze_bdev: kill bd_mount_sem Fernando Luis Vázquez Cao
2009-08-27 14:06 ` [PATCH 2/4] freeze_bdev: grab active reference to frozen superblocks Fernando Luis Vázquez Cao
2009-08-27 14:06 ` [PATCH 3/4] Do not allow umounting of frozen filesystems Fernando Luis Vázquez Cao
2009-09-22 11:07 ` Al Viro
2009-09-22 15:57 ` Eric Sandeen
2009-09-22 16:46 ` Fernando Luis Vazquez Cao
2009-09-22 16:41 ` Fernando Luis Vazquez Cao
2009-08-27 14:06 ` Fernando Luis Vázquez Cao [this message]
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=4A9692DA.20805@oss.ntt.co.jp \
--to=fernando@oss.ntt.co.jp \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=m-hamaguchi@ys.jp.nec.com \
--cc=sandeen@redhat.com \
--cc=t-sato@yk.jp.nec.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.