Skip to contentSkip to conversation

f2fs: fix wrong unlock_page call

PATCH In review Jaegeuk Kim 3 participants 18 messages Jan 8, 2015 – Jan 9, 2015

Subsystems (3)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/6 f2fs: fix wrong unlock_page call

This patch removes wrongly called unlock_page.

---
 fs/f2fs/data.c | 1 -
 1 file changed, 1 deletion(-)
fs/f2fs/data.c +0 -1
index b48b355..a7b905c 100644
@@ -837,7 +837,6 @@ write:
 	/* we should bypass data pages to proceed the kworkder jobs */
 	if (unlikely(f2fs_cp_error(sbi))) {
 		SetPageError(page);
-		unlock_page(page);
 		goto out;
 	}
 
Signature · 9 lines
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
author maintainer
#1 lore raw

PATCH 2/6 f2fs: support goingdown for fs shutdown

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

---
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/file.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
fs/f2fs/f2fs.h +1 -0
index ba30218..febad35 100644
@@ -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)
 /*
fs/f2fs/file.c +14 -0
index 5df3367..de2f669 100644
@@ -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:
Signature · 9 lines
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
#2 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

That way any test using it will "just work" on f2fs...

-Eric

Quoted 43 lines
---
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/file.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
fs/f2fs/f2fs.h +1 -0
index ba30218..febad35 100644
@@ -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)
 /*
fs/f2fs/file.c +12 -0
index 5df3367..de2f669 100644
@@ -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);

fs/f2fs/file.c long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) · line 1086

Quoted 8 lines
fs/f2fs/file.c +2 -0
@@ -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:

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net

author maintainer
#3 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

The semantics are not same for now.
In order to reuse xfs ioctl, it needs to support options for flushing logs.

Thanks,

Quoted 48 lines

That way any test using it will "just work" on f2fs...

-Eric

Quoted 43 lines
---
 fs/f2fs/f2fs.h |  1 +
 fs/f2fs/file.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
fs/f2fs/f2fs.h +1 -0
index ba30218..febad35 100644
@@ -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)
 /*
fs/f2fs/file.c +12 -0
index 5df3367..de2f669 100644
@@ -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);
Quoted 8 lines

fs/f2fs/file.c long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) · line 1086

Quoted 8 lines
fs/f2fs/file.c +2 -0
 	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:

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net

#4 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

The semantics are not same for now.
In order to reuse xfs ioctl, it needs to support options for flushing logs.

the xfs iotl has 3 behaviors optional:

#define XFS_FSOP_GOING_FLAGS_DEFAULT            0x0     /* going down */
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH           0x1     /* flush log but not data */
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH         0x2     /* don't flush log nor data */

if f2fs currently supports a subset, you could just -EOPNOTSUPP on the others.

If the semantics are completely different, maybe it shouldn't share the name at all. ;)

Just a thought...

-Eric

Quoted 6 lines

Thanks,

Quoted 4 lines

That way any test using it will "just work" on f2fs...

-Eric

#5 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 12 lines · Eric Sandeen
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

The semantics are not same for now.
In order to reuse xfs ioctl, it needs to support options for flushing logs.

Quoted 7 lines

the xfs iotl has 3 behaviors optional:

#define XFS_FSOP_GOING_FLAGS_DEFAULT            0x0     /* going down */
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH           0x1     /* flush log but not data */
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH         0x2     /* don't flush log nor data */

if f2fs currently supports a subset, you could just -EOPNOTSUPP on the others.

No, just do a default shutdown operation if the semantics cannot be supported.

- XFS_FSOP_GOING_FLAGS_DEFAULT ==
consistent on disk before shutdown
+ implemented by freeze/thaw/shutdown sequence
- XFS_FSOP_GOING_FLAGS_LOGFLUSH ==
consistent journal on disk before shutdown
+ implemented by journal flush/shutdown sequence
- XFS_FSOP_GOING_FLAGS_NOLOGFLUSH ==
nothing consistent on disk before shutdown
+ just a shutdown call.

f2fs can at least support XFS_FSOP_GOING_FLAGS_DEFAULT and XFS_FSOP_GOING_FLAGS_NOLOGFLUSH....

Quoted 2 lines

If the semantics are completely different, maybe it shouldn't share the name at all. ;)

The semantics are quite clear and generic - when you look at what they actually mean rather than looking at the implementation. There's no need for new ioctls here.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author maintainer
#6 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 37 lines · Dave Chinner
Quoted 12 lines · Eric Sandeen
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

The semantics are not same for now.
In order to reuse xfs ioctl, it needs to support options for flushing logs.

Quoted 7 lines

the xfs iotl has 3 behaviors optional:

#define XFS_FSOP_GOING_FLAGS_DEFAULT            0x0     /* going down */
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH           0x1     /* flush log but not data */
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH         0x2     /* don't flush log nor data */

if f2fs currently supports a subset, you could just -EOPNOTSUPP on the others.

No, just do a default shutdown operation if the semantics cannot be supported.

- XFS_FSOP_GOING_FLAGS_DEFAULT ==
consistent on disk before shutdown
+ implemented by freeze/thaw/shutdown sequence
- XFS_FSOP_GOING_FLAGS_LOGFLUSH ==
consistent journal on disk before shutdown
+ implemented by journal flush/shutdown sequence
- XFS_FSOP_GOING_FLAGS_NOLOGFLUSH ==
nothing consistent on disk before shutdown
+ just a shutdown call.

f2fs can at least support XFS_FSOP_GOING_FLAGS_DEFAULT and XFS_FSOP_GOING_FLAGS_NOLOGFLUSH....

Quoted 6 lines
Quoted 2 lines

If the semantics are completely different, maybe it shouldn't share the name at all. ;)

The semantics are quite clear and generic - when you look at what they actually mean rather than looking at the implementation. There's no need for new ioctls here.

I'll check it out.
Thank you, Dave and Eric. :)

Quoted 7 lines

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#7 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 25 lines · Jaegeuk Kim
Quoted 24 lines · Dave Chinner
Quoted 12 lines · Eric Sandeen
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

The semantics are not same for now.
In order to reuse xfs ioctl, it needs to support options for flushing logs.

Quoted 7 lines

the xfs iotl has 3 behaviors optional:

#define XFS_FSOP_GOING_FLAGS_DEFAULT            0x0     /* going down */
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH           0x1     /* flush log but not data */
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH         0x2     /* don't flush log nor data */

if f2fs currently supports a subset, you could just -EOPNOTSUPP on the others.

No, just do a default shutdown operation if the semantics cannot be supported.

Quoted 6 lines
Quoted 6 lines

- XFS_FSOP_GOING_FLAGS_DEFAULT ==
consistent on disk before shutdown
+ implemented by freeze/thaw/shutdown sequence
- XFS_FSOP_GOING_FLAGS_LOGFLUSH ==
consistent journal on disk before shutdown
+ implemented by journal flush/shutdown sequence

I should point out that this is really "consistent metadata on disk before shutdown", so it really doesn't matter if your filesystem has a journal or not, it can still be implemented.

Perhaps it woul dbe best to rename them for a generic ioctl to FS_GOING_DOWN_SYNC, FS_GOING_DOWN_METADATA_METASYNC and FS_GOING_DOWN_NOSYNC...

Cheers,

Dave.

Signature · 9 lines
Dave Chinner
[email protected]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
author maintainer
#8 lore raw

Re: [PATCH 2/6] f2fs: support goingdown for fs shutdown

Quoted 33 lines · Dave Chinner
Quoted 25 lines · Jaegeuk Kim
Quoted 24 lines · Dave Chinner
Quoted 12 lines · Eric Sandeen
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Eric Sandeen
Quoted 2 lines · Jaegeuk Kim

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

would it make sense to just re-use the xfs ioctl nr, if the semantics are the same?

The semantics are not same for now.
In order to reuse xfs ioctl, it needs to support options for flushing logs.

Quoted 7 lines

the xfs iotl has 3 behaviors optional:

#define XFS_FSOP_GOING_FLAGS_DEFAULT            0x0     /* going down */
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH           0x1     /* flush log but not data */
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH         0x2     /* don't flush log nor data */

if f2fs currently supports a subset, you could just -EOPNOTSUPP on the others.

No, just do a default shutdown operation if the semantics cannot be supported.

Quoted 6 lines
Quoted 6 lines

- XFS_FSOP_GOING_FLAGS_DEFAULT ==
consistent on disk before shutdown
+ implemented by freeze/thaw/shutdown sequence
- XFS_FSOP_GOING_FLAGS_LOGFLUSH ==
consistent journal on disk before shutdown
+ implemented by journal flush/shutdown sequence

Quoted 3 lines

I should point out that this is really "consistent metadata on disk before shutdown", so it really doesn't matter if your filesystem has a journal or not, it can still be implemented.

Agreed. I just implemented these three options for f2fs.

For the f2fs perspective, DEFAULT conducts
- flushing all the user and dentry blocks
- checkpointing and then shutdowning fs

LOGFLUSH conducts
- checkpointing and then shutdowning fs

NOLOGFLUSH conducts
- shutdowning fs

Quoted 4 lines

Perhaps it woul dbe best to rename them for a generic ioctl to FS_GOING_DOWN_SYNC, FS_GOING_DOWN_METADATA_METASYNC and FS_GOING_DOWN_NOSYNC...

How about FS_GOING_DOWN_FULLSYNC, FS_GOING_DOWN_METASYNC, and FS_GOING_DOWN_NOSYNC?

Thanks,

Quoted 7 lines

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net

author maintainer
#9 lore raw

Re: [f2fs-dev] [PATCH 2/6 v2] f2fs: support goingdown for fs shutdown

Change log from v1:
o introduce FS_IOC_GOINGDOWN ioctl
o introduce three options: FS_GOING_DOWN_FULLSYNC, FS_GOING_DOWN_METASYNC, and FS_GOING_DOWN_NOSYNC

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

The ioctl, FS_IOC_GOINGDOWN, provides the following three options.

1. FS_GOING_DOWN_FULLSYNC
: this will flush all the data and dentry blocks, and do checkpoint before shutdown.

2. FS_GOING_DOWN_METASYNC
: this will do checkpoint before shutdown.

3. FS_GOING_DOWN_NOSYNC
: this will trigger shutdown as is.

---
 fs/f2fs/file.c          | 37 +++++++++++++++++++++++++++++++++++++
 include/uapi/linux/fs.h |  8 ++++++++
 2 files changed, 45 insertions(+)
fs/f2fs/file.c +37 -0
index 5df3367..474fb91 100644
@@ -1020,6 +1020,41 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp)
 	return ret;
 }
 
+static int f2fs_ioc_goingdown(struct file *filp, unsigned long arg)
+{
+	struct inode *inode = file_inode(filp);
+	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+	struct super_block *sb = sbi->sb;
+	__u32 in;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	if (get_user(in, (__u32 __user *)arg))
+		return -EFAULT;
+
+	switch (in) {
+	case FS_GOING_DOWN_FULLSYNC:
+		sb = freeze_bdev(sb->s_bdev);
+		if (sb && !IS_ERR(sb)) {
+			f2fs_stop_checkpoint(sbi);
+			thaw_bdev(sb->s_bdev, sb);
+		}
+		break;
+	case FS_GOING_DOWN_METASYNC:
+		/* do checkpoint only */
+		f2fs_sync_fs(sb, 1);
+		f2fs_stop_checkpoint(sbi);
+		break;
+	case FS_GOING_DOWN_NOSYNC:
+		f2fs_stop_checkpoint(sbi);
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static int f2fs_ioc_fitrim(struct file *filp, unsigned long arg)
 {
 	struct inode *inode = file_inode(filp);
@@ -1067,6 +1102,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 FS_IOC_GOINGDOWN:
+		return f2fs_ioc_goingdown(filp, arg);
 	case FITRIM:
 		return f2fs_ioc_fitrim(filp, arg);
 	default:
include/uapi/linux/fs.h +8 -0
index 3735fa0..f37c699 100644
@@ -157,6 +157,7 @@ struct inodes_stat_t {
 #define FIFREEZE	_IOWR('X', 119, int)	/* Freeze */
 #define FITHAW		_IOWR('X', 120, int)	/* Thaw */
 #define FITRIM		_IOWR('X', 121, struct fstrim_range)	/* Trim */
+#define FS_IOC_GOINGDOWN	_IOR('X', 125, __u32)	/* shutdown */
 
 #define	FS_IOC_GETFLAGS			_IOR('f', 1, long)
 #define	FS_IOC_SETFLAGS			_IOW('f', 2, long)
@@ -205,4 +206,11 @@ struct inodes_stat_t {
 #define SYNC_FILE_RANGE_WRITE		2
 #define SYNC_FILE_RANGE_WAIT_AFTER	4
 
+/*
+ * Flags for going down operation used by FS_IOC_GOINGDOWN
+ */
+#define FS_GOING_DOWN_FULLSYNC	0x0	/* going down with full sync */
+#define FS_GOING_DOWN_METASYNC	0x1	/* going down with metadata */
+#define FS_GOING_DOWN_NOSYNC	0x2	/* going down */
+
 #endif /* _UAPI_LINUX_FS_H */
Signature · 9 lines
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
#10 lore raw

Re: [f2fs-dev] [PATCH 2/6 v2] f2fs: support goingdown for fs shutdown

Quoted 4 lines · Jaegeuk Kim

Change log from v1:
o introduce FS_IOC_GOINGDOWN ioctl
o introduce three options: FS_GOING_DOWN_FULLSYNC, FS_GOING_DOWN_METASYNC, and FS_GOING_DOWN_NOSYNC

.....

Quoted 14 lines
include/uapi/linux/fs.h +1 -0
index 3735fa0..f37c699 100644
@@ -157,6 +157,7 @@ struct inodes_stat_t {
 #define FIFREEZE	_IOWR('X', 119, int)	/* Freeze */
 #define FITHAW		_IOWR('X', 120, int)	/* Thaw */
 #define FITRIM		_IOWR('X', 121, struct fstrim_range)	/* Trim */
+#define FS_IOC_GOINGDOWN	_IOR('X', 125, __u32)	/* shutdown */
 
 #define	FS_IOC_GETFLAGS			_IOR('f', 1, long)
 #define	FS_IOC_SETFLAGS			_IOW('f', 2, long)
@@ -205,4 +206,11 @@ struct inodes_stat_t {
 #define SYNC_FILE_RANGE_WRITE		2

include/uapi/linux/fs.h struct inodes_stat_t { · line 216

Quoted 10 lines
include/uapi/linux/fs.h +7 -0
 #define SYNC_FILE_RANGE_WAIT_AFTER	4
 
+/*
+ * Flags for going down operation used by FS_IOC_GOINGDOWN
+ */
+#define FS_GOING_DOWN_FULLSYNC	0x0	/* going down with full sync */
+#define FS_GOING_DOWN_METASYNC	0x1	/* going down with metadata */
+#define FS_GOING_DOWN_NOSYNC	0x2	/* going down */
+
 #endif /* _UAPI_LINUX_FS_H */

This is a separate patch - the first patch in the series should add these definitions and define the XFS ioctl and flags to use them so we can clearly see there is no change of the existing user API. There's no need to change the XFS implementation at all.

The second patch then adds the f2fs implementation.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author maintainer
#11 lore raw

PATCH 1/1 xfs: use generic FS_IOC_GOINGDOWN for ioctl

In reply to Jaegeuk Kim

This patch uses XFS_IOC_GOINGDOWN for a generic ioctl command, FS_IOC_GOINGDOWN.

---
 fs/xfs/xfs_fs.h    | 2 +-
 fs/xfs/xfs_fsops.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/xfs/xfs_fs.h +1 -1
index 18dc721..487a92c 100644
@@ -555,7 +555,7 @@ typedef struct xfs_swapext
 #define XFS_IOC_ATTRLIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
 #define XFS_IOC_ATTRMULTI_BY_HANDLE  _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
 #define XFS_IOC_FSGEOMETRY	     _IOR ('X', 124, struct xfs_fsop_geom)
-#define XFS_IOC_GOINGDOWN	     _IOR ('X', 125, __uint32_t)
+#define XFS_IOC_GOINGDOWN	     FS_IOC_GOINGDOWN
 /*	XFS_IOC_GETFSUUID ---------- deprecated 140	 */
 
 
fs/xfs/xfs_fsops.c +3 -3
index fdc6422..f403664 100644
@@ -793,7 +793,7 @@ xfs_fs_goingdown(
 	__uint32_t	inflags)
 {
 	switch (inflags) {
-	case XFS_FSOP_GOING_FLAGS_DEFAULT: {
+	case FS_GOING_DOWN_FULLSYNC: {
 		struct super_block *sb = freeze_bdev(mp->m_super->s_bdev);
 
 		if (sb && !IS_ERR(sb)) {
@@ -803,10 +803,10 @@ xfs_fs_goingdown(
 
 		break;
 	}
-	case XFS_FSOP_GOING_FLAGS_LOGFLUSH:
+	case FS_GOING_DOWN_METASYNC:
 		xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT);
 		break;
-	case XFS_FSOP_GOING_FLAGS_NOLOGFLUSH:
+	case FS_GOING_DOWN_NOSYNC:
 		xfs_force_shutdown(mp,
 				SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR);
 		break;
Signature · 1 line
2.1.1
author maintainer
#12 lore raw

Re: [PATCH v2] xfs: use generic FS_IOC_GOINGDOWN for ioctl

Change log from v1:
o remove the obsolete options.

-- >8 --

This patch uses XFS_IOC_GOINGDOWN for a generic ioctl command, FS_IOC_GOINGDOWN.

---
 fs/xfs/xfs_fs.h    | 9 +--------
 fs/xfs/xfs_fsops.c | 6 +++---
 2 files changed, 4 insertions(+), 11 deletions(-)
fs/xfs/xfs_fs.h +1 -8
index 18dc721..a44f528 100644
@@ -482,13 +482,6 @@ typedef struct xfs_swapext
 } xfs_swapext_t;
 
 /*
- * Flags for going down operation
- */
-#define XFS_FSOP_GOING_FLAGS_DEFAULT		0x0	/* going down */
-#define XFS_FSOP_GOING_FLAGS_LOGFLUSH		0x1	/* flush log but not data */
-#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH		0x2	/* don't flush log nor data */
-
-/*
  * ioctl commands that are used by Linux filesystems
  */
 #define XFS_IOC_GETXFLAGS	FS_IOC_GETFLAGS
@@ -555,7 +548,7 @@ typedef struct xfs_swapext
 #define XFS_IOC_ATTRLIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
 #define XFS_IOC_ATTRMULTI_BY_HANDLE  _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
 #define XFS_IOC_FSGEOMETRY	     _IOR ('X', 124, struct xfs_fsop_geom)
-#define XFS_IOC_GOINGDOWN	     _IOR ('X', 125, __uint32_t)
+#define XFS_IOC_GOINGDOWN	     FS_IOC_GOINGDOWN
 /*	XFS_IOC_GETFSUUID ---------- deprecated 140	 */
 
 
fs/xfs/xfs_fsops.c +3 -3
index fdc6422..f403664 100644
@@ -793,7 +793,7 @@ xfs_fs_goingdown(
 	__uint32_t	inflags)
 {
 	switch (inflags) {
-	case XFS_FSOP_GOING_FLAGS_DEFAULT: {
+	case FS_GOING_DOWN_FULLSYNC: {
 		struct super_block *sb = freeze_bdev(mp->m_super->s_bdev);
 
 		if (sb && !IS_ERR(sb)) {
@@ -803,10 +803,10 @@ xfs_fs_goingdown(
 
 		break;
 	}
-	case XFS_FSOP_GOING_FLAGS_LOGFLUSH:
+	case FS_GOING_DOWN_METASYNC:
 		xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT);
 		break;
-	case XFS_FSOP_GOING_FLAGS_NOLOGFLUSH:
+	case FS_GOING_DOWN_NOSYNC:
 		xfs_force_shutdown(mp,
 				SHUTDOWN_FORCE_UMOUNT | SHUTDOWN_LOG_IO_ERROR);
 		break;
Signature · 1 line
2.1.1
#13 lore raw

Re: [PATCH v2] xfs: use generic FS_IOC_GOINGDOWN for ioctl

Quoted 6 lines · Jaegeuk Kim

Change log from v1:
o remove the obsolete options.

-- >8 --

This patch uses XFS_IOC_GOINGDOWN for a generic ioctl command, FS_IOC_GOINGDOWN.

Please send the initial rename patch and the XFS changing patches as a linked series to the same mailing lists.

Quoted 12 lines
---
 fs/xfs/xfs_fs.h    | 9 +--------
 fs/xfs/xfs_fsops.c | 6 +++---
 2 files changed, 4 insertions(+), 11 deletions(-)
fs/xfs/xfs_fs.h +0 -0
index 18dc721..a44f528 100644

fs/xfs/xfs_fs.h typedef struct xfs_swapext · line 489

Quoted 8 lines
fs/xfs/xfs_fs.h +0 -5
@@ -482,13 +482,6 @@ typedef struct xfs_swapext
 } xfs_swapext_t;
 
 /*
- * Flags for going down operation
- */
-#define XFS_FSOP_GOING_FLAGS_DEFAULT		0x0	/* going down */
-#define XFS_FSOP_GOING_FLAGS_LOGFLUSH		0x1	/* flush log but not data */
-#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH		0x2	/* don't flush log nor data */

We are going to need those to remain as we have to support them forever more.

i.e.

#define XFS_FSOP_GOING_FLAGS_DEFAULT FS_SHUTDOWN_FULLSYNC
#define XFS_FSOP_GOING_FLAGS_LOGFLUSH FS_SHUTDOWN_METASYNC
#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH FS_SHUTDOWN_NOSYNC

fs/xfs/xfs_fs.h typedef struct xfs_swapext · line 552

Quoted 12 lines
fs/xfs/xfs_fs.h +1 -3
-
-/*
  * ioctl commands that are used by Linux filesystems
  */
 #define XFS_IOC_GETXFLAGS	FS_IOC_GETFLAGS
@@ -555,7 +548,7 @@ typedef struct xfs_swapext
 #define XFS_IOC_ATTRLIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
 #define XFS_IOC_ATTRMULTI_BY_HANDLE  _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
 #define XFS_IOC_FSGEOMETRY	     _IOR ('X', 124, struct xfs_fsop_geom)
-#define XFS_IOC_GOINGDOWN	     _IOR ('X', 125, __uint32_t)
+#define XFS_IOC_GOINGDOWN	     FS_IOC_GOINGDOWN
 /*	XFS_IOC_GETFSUUID ---------- deprecated 140	 */

Can we call the new ioctl name FS_IOC_SHUTDOWN?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author maintainer
#14 lore raw

PATCH 3/6 f2fs: free radix_tree_nodes used by nat_set entries

In reply to Jaegeuk Kim

In the normal case, the radix_tree_nodes are freed successfully. But, when cp_error was detected, we should destroy them forcefully.

---
 fs/f2fs/node.c | 21 +++++++++++++++++++--
 fs/f2fs/node.h |  1 +
 2 files changed, 20 insertions(+), 2 deletions(-)
fs/f2fs/node.c +19 -2
index 9bed016..d7c1436 100644
@@ -1894,7 +1894,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
 	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
 	struct f2fs_summary_block *sum = curseg->sum_blk;
-	struct nat_entry_set *setvec[NATVEC_SIZE];
+	struct nat_entry_set *setvec[SETVEC_SIZE];
 	struct nat_entry_set *set, *tmp;
 	unsigned int found;
 	nid_t set_idx = 0;
@@ -1911,7 +1911,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
 		remove_nats_in_journal(sbi);
 
 	while ((found = __gang_lookup_nat_set(nm_i,
-					set_idx, NATVEC_SIZE, setvec))) {
+					set_idx, SETVEC_SIZE, setvec))) {
 		unsigned idx;
 		set_idx = setvec[found - 1]->set + 1;
 		for (idx = 0; idx < found; idx++)
@@ -1991,6 +1991,7 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
 	struct f2fs_nm_info *nm_i = NM_I(sbi);
 	struct free_nid *i, *next_i;
 	struct nat_entry *natvec[NATVEC_SIZE];
+	struct nat_entry_set *setvec[SETVEC_SIZE];
 	nid_t nid = 0;
 	unsigned int found;
 
@@ -2015,11 +2016,27 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
 	while ((found = __gang_lookup_nat_cache(nm_i,
 					nid, NATVEC_SIZE, natvec))) {
 		unsigned idx;
+
 		nid = nat_get_nid(natvec[found - 1]) + 1;
 		for (idx = 0; idx < found; idx++)
 			__del_from_nat_cache(nm_i, natvec[idx]);
 	}
 	f2fs_bug_on(sbi, nm_i->nat_cnt);
+
+	/* destroy nat set cache */
+	nid = 0;
+	while ((found = __gang_lookup_nat_set(nm_i,
+					nid, SETVEC_SIZE, setvec))) {
+		unsigned idx;
+
+		nid = setvec[found - 1]->set + 1;
+		for (idx = 0; idx < found; idx++) {
+			/* entry_cnt is not zero, when cp_error was occurred */
+			f2fs_bug_on(sbi, !list_empty(&setvec[idx]->entry_list));
+			radix_tree_delete(&nm_i->nat_set_root, setvec[idx]->set);
+			kmem_cache_free(nat_entry_set_slab, setvec[idx]);
+		}
+	}
 	up_write(&nm_i->nat_tree_lock);
 
 	kfree(nm_i->nat_bitmap);
fs/f2fs/node.h +1 -0
index cac8a3d..f405bbf 100644
@@ -25,6 +25,7 @@
 
 /* vector size for gang look-up from nat cache that consists of radix tree */
 #define NATVEC_SIZE	64
+#define SETVEC_SIZE	32
 
 /* return value for read_node_page */
 #define LOCKED_PAGE	1
Signature · 1 line
2.1.1
author maintainer
#15 lore raw

PATCH 4/6 f2fs: add nat/sit entries into status

In reply to Jaegeuk Kim

This patch adds NAT/SIT entry informations.

---
 fs/f2fs/debug.c | 8 +++++---
 fs/f2fs/f2fs.h  | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)
fs/f2fs/debug.c +5 -3
index dd7835b..1f0fb58 100644
@@ -57,7 +57,9 @@ static void update_general_status(struct f2fs_sb_info *sbi)
 	si->node_pages = NODE_MAPPING(sbi)->nrpages;
 	si->meta_pages = META_MAPPING(sbi)->nrpages;
 	si->nats = NM_I(sbi)->nat_cnt;
-	si->sits = SIT_I(sbi)->dirty_sentries;
+	si->dirty_nats = NM_I(sbi)->dirty_nat_cnt;
+	si->sits = MAIN_SEGS(sbi);
+	si->dirty_sits = SIT_I(sbi)->dirty_sentries;
 	si->fnids = NM_I(sbi)->fcnt;
 	si->bg_gc = sbi->bg_gc;
 	si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg)
@@ -260,8 +262,8 @@ static int stat_show(struct seq_file *s, void *v)
 			   si->ndirty_dent, si->ndirty_dirs);
 		seq_printf(s, "  - meta: %4d in %4d\n",
 			   si->ndirty_meta, si->meta_pages);
-		seq_printf(s, "  - NATs: %9d\n  - SITs: %9d\n",
-			   si->nats, si->sits);
+		seq_printf(s, "  - NATs: %9d/%9d\n  - SITs: %9d/%9d\n",
+			   si->dirty_nats, si->nats, si->dirty_sits, si->sits);
 		seq_printf(s, "  - free_nids: %9d\n",
 			   si->fnids);
 		seq_puts(s, "\nDistribution of User Blocks:");
fs/f2fs/f2fs.h +1 -1
index febad35..d39b230 100644
@@ -1513,7 +1513,7 @@ struct f2fs_stat_info {
 	int main_area_segs, main_area_sections, main_area_zones;
 	int hit_ext, total_ext;
 	int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta;
-	int nats, sits, fnids;
+	int nats, dirty_nats, sits, dirty_sits, fnids;
 	int total_count, utilization;
 	int bg_gc, inline_inode, inline_dir, inmem_pages;
 	unsigned int valid_count, valid_node_count, valid_inode_count;
Signature · 1 line
2.1.1
author maintainer
#16 lore raw

PATCH 5/6 f2fs: add spin_lock to cover radix operations in IO tracer

In reply to Jaegeuk Kim

This patch adds spin_lock to cover radix tree operations in IO tracer.

---
 fs/f2fs/super.c |  2 ++
 fs/f2fs/trace.c | 18 +++++++++++++++---
 fs/f2fs/trace.h |  2 ++
 3 files changed, 19 insertions(+), 3 deletions(-)
fs/f2fs/super.c +2 -0
index 0ae6a2f..e6f035c 100644
@@ -1222,6 +1222,8 @@ static int __init init_f2fs_fs(void)
 {
 	int err;
 
+	f2fs_build_trace_ios();
+
 	err = init_inodecache();
 	if (err)
 		goto fail;
fs/f2fs/trace.c +15 -3
index 19f5216..92fa38a 100644
@@ -15,7 +15,8 @@
 #include "f2fs.h"
 #include "trace.h"
 
-RADIX_TREE(pids, GFP_NOIO);
+RADIX_TREE(pids, GFP_ATOMIC);
+spinlock_t pids_lock;
 struct last_io_info last_io;
 
 static inline void __print_last_io(void)
@@ -58,9 +59,13 @@ void f2fs_trace_pid(struct page *page)
 
 	page->private = pid;
 
+	if (radix_tree_preload(GFP_NOFS))
+		return;
+
+	spin_lock(&pids_lock);
 	p = radix_tree_lookup(&pids, pid);
 	if (p == current)
-		return;
+		goto out;
 	if (p)
 		radix_tree_delete(&pids, pid);
 
@@ -69,7 +74,9 @@ void f2fs_trace_pid(struct page *page)
 	trace_printk("%3x:%3x %4x %-16s\n",
 			MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev),
 			pid, current->comm);
-
+out:
+	spin_unlock(&pids_lock);
+	radix_tree_preload_end();
 }
 
 void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush)
@@ -108,3 +115,8 @@ void f2fs_trace_ios(struct page *page, struct f2fs_io_info *fio, int flush)
 	last_io.len = 1;
 	return;
 }
+
+void f2fs_build_trace_ios(void)
+{
+	spin_lock_init(&pids_lock);
+}
fs/f2fs/trace.h +2 -0
index aa6663b..eb39fa0 100644
@@ -34,9 +34,11 @@ struct last_io_info {
 
 extern void f2fs_trace_pid(struct page *);
 extern void f2fs_trace_ios(struct page *, struct f2fs_io_info *, int);
+extern void f2fs_build_trace_ios(void);
 #else
 #define f2fs_trace_pid(p)
 #define f2fs_trace_ios(p, i, n)
+#define f2fs_build_trace_ios()
 
 #endif
 #endif /* __F2FS_TRACE_H__ */
Signature · 9 lines
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
author maintainer
#17 lore raw

PATCH 6/6 f2fs: add f2fs_destroy_trace_ios to free radix tree

In reply to Jaegeuk Kim

This patch removes radix tree after finishing tracing IOs.

---
 fs/f2fs/super.c |  1 +
 fs/f2fs/trace.c | 37 +++++++++++++++++++++++++++++++++++++
 fs/f2fs/trace.h |  2 ++
 3 files changed, 40 insertions(+)
fs/f2fs/super.c +1 -0
index e6f035c..0e97974 100644
@@ -1272,6 +1272,7 @@ static void __exit exit_f2fs_fs(void)
 	destroy_node_manager_caches();
 	destroy_inodecache();
 	kset_unregister(f2fs_kset);
+	f2fs_destroy_trace_ios();
 }
 
 module_init(init_f2fs_fs)
fs/f2fs/trace.c +37 -0
index 92fa38a..b3570dc 100644
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/f2fs_fs.h>
 #include <linux/sched.h>
+#include <linux/radix-tree.h>
 
 #include "f2fs.h"
 #include "trace.h"
@@ -120,3 +121,39 @@ void f2fs_build_trace_ios(void)
 {
 	spin_lock_init(&pids_lock);
 }
+
+#define PIDVEC_SIZE	128
+static unsigned int gang_lookup_pids(pid_t *results, unsigned long first_index,
+							unsigned int max_items)
+{
+	struct radix_tree_iter iter;
+	void **slot;
+	unsigned int ret = 0;
+
+	if (unlikely(!max_items))
+		return 0;
+
+	radix_tree_for_each_slot(slot, &pids, &iter, first_index) {
+		results[ret] = iter.index;
+		if (++ret == PIDVEC_SIZE)
+			break;
+	}
+	return ret;
+}
+
+void f2fs_destroy_trace_ios(void)
+{
+	pid_t pid[PIDVEC_SIZE];
+	pid_t next_pid = 0;
+	unsigned int found;
+
+	spin_lock(&pids_lock);
+	while ((found = gang_lookup_pids(pid, next_pid, PIDVEC_SIZE))) {
+		unsigned idx;
+
+		next_pid = pid[found - 1] + 1;
+		for (idx = 0; idx < found; idx++)
+			radix_tree_delete(&pids, pid[idx]);
+	}
+	spin_unlock(&pids_lock);
+}
fs/f2fs/trace.h +2 -0
index eb39fa0..1041dbe 100644
@@ -35,10 +35,12 @@ struct last_io_info {
 extern void f2fs_trace_pid(struct page *);
 extern void f2fs_trace_ios(struct page *, struct f2fs_io_info *, int);
 extern void f2fs_build_trace_ios(void);
+extern void f2fs_destroy_trace_ios(void);
 #else
 #define f2fs_trace_pid(p)
 #define f2fs_trace_ios(p, i, n)
 #define f2fs_build_trace_ios()
+#define f2fs_destroy_trace_ios()
 
 #endif
 #endif /* __F2FS_TRACE_H__ */
Signature · 1 line
2.1.1