public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 2/6] f2fs: support goingdown for fs shutdown
Date: Thu,  8 Jan 2015 10:10:57 -0800	[thread overview]
Message-ID: <1420740661-72288-2-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1420740661-72288-1-git-send-email-jaegeuk@kernel.org>

This patch add an ioctl to shutdown f2fs, which stops all the further block
writes after this point.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/file.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index ba30218..febad35 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -209,6 +209,7 @@ static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size,
 #define F2FS_IOC_START_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 3)
 #define F2FS_IOC_RELEASE_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 4)
 #define F2FS_IOC_ABORT_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 5)
+#define F2FS_IOC_GOINGDOWN		_IO(F2FS_IOCTL_MAGIC, 6)
 
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /*
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 5df3367..de2f669 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1020,6 +1020,18 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp)
 	return ret;
 }
 
+static int f2fs_ioc_goingdown(struct file *filp)
+{
+	struct inode *inode = file_inode(filp);
+	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	f2fs_stop_checkpoint(sbi);
+	return 0;
+}
+
 static int f2fs_ioc_fitrim(struct file *filp, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -1067,6 +1079,8 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		return f2fs_ioc_release_volatile_write(filp);
 	case F2FS_IOC_ABORT_VOLATILE_WRITE:
 		return f2fs_ioc_abort_volatile_write(filp);
+	case F2FS_IOC_GOINGDOWN:
+		return f2fs_ioc_goingdown(filp);
 	case FITRIM:
 		return f2fs_ioc_fitrim(filp, arg);
 	default:
-- 
2.1.1


  reply	other threads:[~2015-01-08 18:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-08 18:10 [PATCH 1/6] f2fs: fix wrong unlock_page call Jaegeuk Kim
2015-01-08 18:10 ` Jaegeuk Kim [this message]
2015-01-08 19:54   ` [PATCH 2/6] f2fs: support goingdown for fs shutdown Eric Sandeen
2015-01-08 20:18     ` Jaegeuk Kim
2015-01-08 20:33       ` Eric Sandeen
2015-01-08 20:54         ` Dave Chinner
2015-01-08 21:21           ` Jaegeuk Kim
2015-01-08 22:04             ` Dave Chinner
2015-01-08 22:16               ` Jaegeuk Kim
2015-01-09  1:40                 ` [f2fs-dev] [PATCH 2/6 v2] " Jaegeuk Kim
2015-01-09  2:24                   ` Dave Chinner
2015-01-09  1:41                 ` [PATCH] xfs: use generic FS_IOC_GOINGDOWN for ioctl Jaegeuk Kim
2015-01-09  1:48                   ` [PATCH v2] " Jaegeuk Kim
2015-01-09  2:17                     ` Dave Chinner
2015-01-08 18:10 ` [PATCH 3/6] f2fs: free radix_tree_nodes used by nat_set entries Jaegeuk Kim
2015-01-08 18:10 ` [PATCH 4/6] f2fs: add nat/sit entries into status Jaegeuk Kim
2015-01-08 18:11 ` [PATCH 5/6] f2fs: add spin_lock to cover radix operations in IO tracer Jaegeuk Kim
2015-01-08 18:11 ` [PATCH 6/6] f2fs: add f2fs_destroy_trace_ios to free radix tree Jaegeuk Kim

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=1420740661-72288-2-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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