From: Daeho Jeong <daeho43@gmail.com>
To: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>
Subject: [f2fs-dev] [PATCH 2/2] f2fs: add volume_name mount option
Date: Sun, 19 Jul 2020 14:44:09 +0900 [thread overview]
Message-ID: <20200719054409.3050516-2-daeho43@gmail.com> (raw)
In-Reply-To: <20200719054409.3050516-1-daeho43@gmail.com>
From: Daeho Jeong <daehojeong@google.com>
Added "volume_name" mount option. When the volume name in the on-disk
superblock doesn't exist, we can input the volume name as a mount
option and this is used to create a sysfs symbolic link pointing to
/sys/fs/f2fs/<disk>. The format of the symbolic directory link is like
/sys/fs/f2fs/<volume_name>_<num>, <volume_name> is the passed volume
name and <num> means the order of mounting with the same volume name.
When the on-disk volume name already exists, this mount option will be
ignored.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
Documentation/filesystems/f2fs.rst | 8 ++++++++
fs/f2fs/super.c | 23 +++++++++++++++++++++++
fs/f2fs/sysfs.c | 14 +++++++++++---
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
index 8221f3af6042..07507bed4fc1 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -260,6 +260,14 @@ compress_extension=%s Support adding specified extension, so that f2fs can enab
For other files, we can still enable compression via ioctl.
Note that, there is one reserved special extension '*', it
can be set to enable compression for all files.
+volume_name=%s When the volume name in the on-disk superblock doesn't exist,
+ we can input the volume name as a mount option and this is
+ used to create a sysfs symbolic link pointing to
+ /sys/fs/f2fs/<disk>. The format of the symbolic directory
+ link is like /sys/fs/f2fs/<volume_name>_<num>, <volume_name>
+ is the passed volume name and <num> means the order of mounting
+ with the same volume name. When the on-disk volume name already
+ exists, this mount option will be ignored.
====================== ============================================================
Debugfs Entries
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7b002785417a..18d0a535697d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -145,6 +145,7 @@ enum {
Opt_compress_algorithm,
Opt_compress_log_size,
Opt_compress_extension,
+ Opt_volume_name,
Opt_err,
};
@@ -211,6 +212,7 @@ static match_table_t f2fs_tokens = {
{Opt_compress_algorithm, "compress_algorithm=%s"},
{Opt_compress_log_size, "compress_log_size=%u"},
{Opt_compress_extension, "compress_extension=%s"},
+ {Opt_volume_name, "volume_name=%s"},
{Opt_err, NULL},
};
@@ -918,6 +920,21 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
F2FS_OPTION(sbi).compress_ext_cnt++;
kfree(name);
break;
+ case Opt_volume_name:
+ name = match_strdup(&args[0]);
+ if (!name)
+ return -ENOMEM;
+
+ if (strlen(name) > MAX_VOLUME_NAME) {
+ f2fs_err(sbi,
+ "Volume name is too long");
+ kfree(name);
+ return -EINVAL;
+ }
+
+ strncpy(sbi->syslink_name, name, MAX_VOLUME_NAME);
+ kfree(name);
+ break;
default:
f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
p);
@@ -1609,6 +1626,12 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
seq_printf(seq, ",fsync_mode=%s", "nobarrier");
f2fs_show_compress_options(seq, sbi->sb);
+
+ mutex_lock(&sbi->syslink_mutex);
+ if (f2fs_has_syslink(sbi))
+ seq_printf(seq, ",volume_name=%s", sbi->syslink_name);
+ mutex_unlock(&sbi->syslink_mutex);
+
return 0;
}
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index e9818dd338c1..6d4a2f8aa0d7 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -907,7 +907,7 @@ static void f2fs_unload_syslink(struct f2fs_sb_info *sbi)
memset(sbi->syslink_name, 0, MAX_SYSLINK_NAME);
}
-static int f2fs_load_syslink(struct f2fs_sb_info *sbi)
+static int f2fs_load_syslink(struct f2fs_sb_info *sbi, bool mount)
{
int idx, count, ret;
@@ -918,6 +918,14 @@ static int f2fs_load_syslink(struct f2fs_sb_info *sbi)
MAX_VOLUME_NAME);
up_read(&sbi->sb_lock);
+ if (mount) {
+ if (count)
+ memset(sbi->syslink_name + count, 0,
+ MAX_SYSLINK_NAME - count);
+ else
+ count = strlen(sbi->syslink_name);
+ }
+
if (!count)
return -ENOENT;
@@ -939,7 +947,7 @@ void f2fs_reload_syslink(struct f2fs_sb_info *sbi)
{
mutex_lock(&sbi->syslink_mutex);
f2fs_unload_syslink(sbi);
- f2fs_load_syslink(sbi);
+ f2fs_load_syslink(sbi, false);
mutex_unlock(&sbi->syslink_mutex);
}
@@ -1001,7 +1009,7 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
victim_bits_seq_show, sb);
}
- f2fs_load_syslink(sbi);
+ f2fs_load_syslink(sbi, true);
return 0;
}
--
2.28.0.rc0.105.gf9edc3c819-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Daeho Jeong <daeho43@gmail.com>
To: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>
Subject: [PATCH 2/2] f2fs: add volume_name mount option
Date: Sun, 19 Jul 2020 14:44:09 +0900 [thread overview]
Message-ID: <20200719054409.3050516-2-daeho43@gmail.com> (raw)
In-Reply-To: <20200719054409.3050516-1-daeho43@gmail.com>
From: Daeho Jeong <daehojeong@google.com>
Added "volume_name" mount option. When the volume name in the on-disk
superblock doesn't exist, we can input the volume name as a mount
option and this is used to create a sysfs symbolic link pointing to
/sys/fs/f2fs/<disk>. The format of the symbolic directory link is like
/sys/fs/f2fs/<volume_name>_<num>, <volume_name> is the passed volume
name and <num> means the order of mounting with the same volume name.
When the on-disk volume name already exists, this mount option will be
ignored.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
Documentation/filesystems/f2fs.rst | 8 ++++++++
fs/f2fs/super.c | 23 +++++++++++++++++++++++
fs/f2fs/sysfs.c | 14 +++++++++++---
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
index 8221f3af6042..07507bed4fc1 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -260,6 +260,14 @@ compress_extension=%s Support adding specified extension, so that f2fs can enab
For other files, we can still enable compression via ioctl.
Note that, there is one reserved special extension '*', it
can be set to enable compression for all files.
+volume_name=%s When the volume name in the on-disk superblock doesn't exist,
+ we can input the volume name as a mount option and this is
+ used to create a sysfs symbolic link pointing to
+ /sys/fs/f2fs/<disk>. The format of the symbolic directory
+ link is like /sys/fs/f2fs/<volume_name>_<num>, <volume_name>
+ is the passed volume name and <num> means the order of mounting
+ with the same volume name. When the on-disk volume name already
+ exists, this mount option will be ignored.
====================== ============================================================
Debugfs Entries
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7b002785417a..18d0a535697d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -145,6 +145,7 @@ enum {
Opt_compress_algorithm,
Opt_compress_log_size,
Opt_compress_extension,
+ Opt_volume_name,
Opt_err,
};
@@ -211,6 +212,7 @@ static match_table_t f2fs_tokens = {
{Opt_compress_algorithm, "compress_algorithm=%s"},
{Opt_compress_log_size, "compress_log_size=%u"},
{Opt_compress_extension, "compress_extension=%s"},
+ {Opt_volume_name, "volume_name=%s"},
{Opt_err, NULL},
};
@@ -918,6 +920,21 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
F2FS_OPTION(sbi).compress_ext_cnt++;
kfree(name);
break;
+ case Opt_volume_name:
+ name = match_strdup(&args[0]);
+ if (!name)
+ return -ENOMEM;
+
+ if (strlen(name) > MAX_VOLUME_NAME) {
+ f2fs_err(sbi,
+ "Volume name is too long");
+ kfree(name);
+ return -EINVAL;
+ }
+
+ strncpy(sbi->syslink_name, name, MAX_VOLUME_NAME);
+ kfree(name);
+ break;
default:
f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
p);
@@ -1609,6 +1626,12 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
seq_printf(seq, ",fsync_mode=%s", "nobarrier");
f2fs_show_compress_options(seq, sbi->sb);
+
+ mutex_lock(&sbi->syslink_mutex);
+ if (f2fs_has_syslink(sbi))
+ seq_printf(seq, ",volume_name=%s", sbi->syslink_name);
+ mutex_unlock(&sbi->syslink_mutex);
+
return 0;
}
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index e9818dd338c1..6d4a2f8aa0d7 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -907,7 +907,7 @@ static void f2fs_unload_syslink(struct f2fs_sb_info *sbi)
memset(sbi->syslink_name, 0, MAX_SYSLINK_NAME);
}
-static int f2fs_load_syslink(struct f2fs_sb_info *sbi)
+static int f2fs_load_syslink(struct f2fs_sb_info *sbi, bool mount)
{
int idx, count, ret;
@@ -918,6 +918,14 @@ static int f2fs_load_syslink(struct f2fs_sb_info *sbi)
MAX_VOLUME_NAME);
up_read(&sbi->sb_lock);
+ if (mount) {
+ if (count)
+ memset(sbi->syslink_name + count, 0,
+ MAX_SYSLINK_NAME - count);
+ else
+ count = strlen(sbi->syslink_name);
+ }
+
if (!count)
return -ENOENT;
@@ -939,7 +947,7 @@ void f2fs_reload_syslink(struct f2fs_sb_info *sbi)
{
mutex_lock(&sbi->syslink_mutex);
f2fs_unload_syslink(sbi);
- f2fs_load_syslink(sbi);
+ f2fs_load_syslink(sbi, false);
mutex_unlock(&sbi->syslink_mutex);
}
@@ -1001,7 +1009,7 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
victim_bits_seq_show, sb);
}
- f2fs_load_syslink(sbi);
+ f2fs_load_syslink(sbi, true);
return 0;
}
--
2.28.0.rc0.105.gf9edc3c819-goog
next prev parent reply other threads:[~2020-07-19 5:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-19 5:44 [f2fs-dev] [PATCH 1/2] f2fs: add sysfs symbolic link to kobject with volume name Daeho Jeong
2020-07-19 5:44 ` Daeho Jeong
2020-07-19 5:44 ` Daeho Jeong [this message]
2020-07-19 5:44 ` [PATCH 2/2] f2fs: add volume_name mount option Daeho Jeong
2020-07-19 9:06 ` [PATCH 1/2] f2fs: add sysfs symbolic link to kobject with volume name kernel test robot
2020-07-19 9:06 ` kernel test robot
2020-07-19 15:16 ` [f2fs-dev] " Greg KH
2020-07-19 15:16 ` Greg KH
2020-07-22 16:43 ` [f2fs-dev] " Jaegeuk Kim
2020-07-22 16:43 ` Jaegeuk Kim
2020-07-22 17:06 ` [f2fs-dev] " Greg KH
2020-07-22 17:06 ` Greg KH
2020-07-22 17:24 ` [f2fs-dev] " Jaegeuk Kim
2020-07-22 17:24 ` Jaegeuk Kim
2020-07-22 19:10 ` [f2fs-dev] " Greg KH
2020-07-22 19:10 ` Greg KH
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=20200719054409.3050516-2-daeho43@gmail.com \
--to=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--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 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.