All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mkfs.f2fs: introduce -b option to support specified fs size formating
@ 2015-11-10  8:48 Chao Yu
  2015-11-14  5:32 ` He YunLei
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2015-11-10  8:48 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel

This patch introduces a new option '-b', with this option user can specify
required fs size for formating. _scratch_mkfs_sized in xfstest is one of
user cases.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 include/f2fs_fs.h       | 1 +
 lib/libf2fs.c           | 9 +++++++--
 mkfs/f2fs_format_main.c | 6 +++++-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 359deec..dedc143 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -223,6 +223,7 @@ enum f2fs_config_func {
 };
 
 struct f2fs_configuration {
+	u_int64_t fs_size;
 	u_int32_t sector_size;
 	u_int32_t reserved_segments;
 	double overprovision;
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 33a82aa..e755f20 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -347,6 +347,7 @@ int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len)
  */
 void f2fs_init_configuration(struct f2fs_configuration *c)
 {
+	c->fs_size = 0;
 	c->total_sectors = 0;
 	c->sector_size = DEFAULT_SECTOR_SIZE;
 	c->sectors_per_blk = DEFAULT_SECTORS_PER_BLOCK;
@@ -473,15 +474,19 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
 			MSG(0, "\tError: Cannot get the device size\n");
 			return -1;
 		}
-		c->total_sectors /= c->sector_size;
 #else
 		if (ioctl(fd, BLKGETSIZE, &total_sectors) < 0) {
 			MSG(0, "\tError: Cannot get the device size\n");
 			return -1;
 		}
-		total_sectors /= c->sector_size;
 		c->total_sectors = total_sectors;
 #endif
+		if (c->fs_size && c->fs_size < c->total_sectors)
+			c->total_sectors = (c->fs_size + c->sector_size - 1) /
+								c->sector_size;
+		else
+			c->total_sectors /= c->sector_size;
+
 		if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
 			c->start_sector = 0;
 		else
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 2ea809c..07f101f 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -29,6 +29,7 @@ static void mkfs_usage()
 	MSG(0, "\nUsage: mkfs.f2fs [options] device [sectors]\n");
 	MSG(0, "[options]:\n");
 	MSG(0, "  -a heap-based allocation [default:1]\n");
+	MSG(0, "  -b file system size\n");
 	MSG(0, "  -d debug level [default:0]\n");
 	MSG(0, "  -e [extension list] e.g. \"mp3,gif,mov\"\n");
 	MSG(0, "  -l label\n");
@@ -73,7 +74,7 @@ static void parse_feature(char *features)
 
 static void f2fs_parse_options(int argc, char *argv[])
 {
-	static const char *option_string = "qa:d:e:l:o:O:s:z:t:";
+	static const char *option_string = "qa:b:d:e:l:o:O:s:z:t:";
 	int32_t option=0;
 
 	while ((option = getopt(argc,argv,option_string)) != EOF) {
@@ -84,6 +85,9 @@ static void f2fs_parse_options(int argc, char *argv[])
 		case 'a':
 			config.heap = atoi(optarg);
 			break;
+		case 'b':
+			config.fs_size = atoll(optarg);
+			break;
 		case 'd':
 			config.dbg_lv = atoi(optarg);
 			break;
-- 
2.6.1



------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mkfs.f2fs: introduce -b option to support specified fs size formating
  2015-11-10  8:48 [PATCH] mkfs.f2fs: introduce -b option to support specified fs size formating Chao Yu
@ 2015-11-14  5:32 ` He YunLei
  2015-11-14 18:27   ` Jaegeuk Kim
  0 siblings, 1 reply; 4+ messages in thread
From: He YunLei @ 2015-11-14  5:32 UTC (permalink / raw)
  To: Chao Yu; +Cc: Jaegeuk Kim, linux-f2fs-devel

hi,

We can specify fs size in function f2fs_parse_options as follow:
     if ((optind + 1) < argc) {
         /* We have a sector count. */
         config.total_sectors = atoll(argv[optind+1]);
which one is better?

Thanks

On 2015/11/10 16:48, Chao Yu wrote:
> This patch introduces a new option '-b', with this option user can specify
> required fs size for formating. _scratch_mkfs_sized in xfstest is one of
> user cases.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>   include/f2fs_fs.h       | 1 +
>   lib/libf2fs.c           | 9 +++++++--
>   mkfs/f2fs_format_main.c | 6 +++++-
>   3 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index 359deec..dedc143 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -223,6 +223,7 @@ enum f2fs_config_func {
>   };
>
>   struct f2fs_configuration {
> +	u_int64_t fs_size;
>   	u_int32_t sector_size;
>   	u_int32_t reserved_segments;
>   	double overprovision;
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 33a82aa..e755f20 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -347,6 +347,7 @@ int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len)
>    */
>   void f2fs_init_configuration(struct f2fs_configuration *c)
>   {
> +	c->fs_size = 0;
>   	c->total_sectors = 0;
>   	c->sector_size = DEFAULT_SECTOR_SIZE;
>   	c->sectors_per_blk = DEFAULT_SECTORS_PER_BLOCK;
> @@ -473,15 +474,19 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
>   			MSG(0, "\tError: Cannot get the device size\n");
>   			return -1;
>   		}
> -		c->total_sectors /= c->sector_size;
>   #else
>   		if (ioctl(fd, BLKGETSIZE, &total_sectors) < 0) {
>   			MSG(0, "\tError: Cannot get the device size\n");
>   			return -1;
>   		}
> -		total_sectors /= c->sector_size;
>   		c->total_sectors = total_sectors;
>   #endif
> +		if (c->fs_size && c->fs_size < c->total_sectors)
> +			c->total_sectors = (c->fs_size + c->sector_size - 1) /
> +								c->sector_size;
> +		else
> +			c->total_sectors /= c->sector_size;
> +
>   		if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
>   			c->start_sector = 0;
>   		else
> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
> index 2ea809c..07f101f 100644
> --- a/mkfs/f2fs_format_main.c
> +++ b/mkfs/f2fs_format_main.c
> @@ -29,6 +29,7 @@ static void mkfs_usage()
>   	MSG(0, "\nUsage: mkfs.f2fs [options] device [sectors]\n");
>   	MSG(0, "[options]:\n");
>   	MSG(0, "  -a heap-based allocation [default:1]\n");
> +	MSG(0, "  -b file system size\n");
>   	MSG(0, "  -d debug level [default:0]\n");
>   	MSG(0, "  -e [extension list] e.g. \"mp3,gif,mov\"\n");
>   	MSG(0, "  -l label\n");
> @@ -73,7 +74,7 @@ static void parse_feature(char *features)
>
>   static void f2fs_parse_options(int argc, char *argv[])
>   {
> -	static const char *option_string = "qa:d:e:l:o:O:s:z:t:";
> +	static const char *option_string = "qa:b:d:e:l:o:O:s:z:t:";
>   	int32_t option=0;
>
>   	while ((option = getopt(argc,argv,option_string)) != EOF) {
> @@ -84,6 +85,9 @@ static void f2fs_parse_options(int argc, char *argv[])
>   		case 'a':
>   			config.heap = atoi(optarg);
>   			break;
> +		case 'b':
> +			config.fs_size = atoll(optarg);
> +			break;
>   		case 'd':
>   			config.dbg_lv = atoi(optarg);
>   			break;
>


------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mkfs.f2fs: introduce -b option to support specified fs size formating
  2015-11-14  5:32 ` He YunLei
@ 2015-11-14 18:27   ` Jaegeuk Kim
  2015-11-15  6:34     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2015-11-14 18:27 UTC (permalink / raw)
  To: He YunLei; +Cc: linux-f2fs-devel

Hello,

On Sat, Nov 14, 2015 at 01:32:29PM +0800, He YunLei wrote:
> hi,
> 
> We can specify fs size in function f2fs_parse_options as follow:
>      if ((optind + 1) < argc) {
>          /* We have a sector count. */
>          config.total_sectors = atoll(argv[optind+1]);
> which one is better?

Yeah, there is.
I don't think we need to add redundant options.

> 
> Thanks
> 
> On 2015/11/10 16:48, Chao Yu wrote:
> > This patch introduces a new option '-b', with this option user can specify
> > required fs size for formating. _scratch_mkfs_sized in xfstest is one of
> > user cases.

We need to add one for f2fs in xfstest.
Actually, I have a patch pending in my local xfstest.
Let me submit that sooner or later. :)

Thanks,

------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mkfs.f2fs: introduce -b option to support specified fs size formating
  2015-11-14 18:27   ` Jaegeuk Kim
@ 2015-11-15  6:34     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2015-11-15  6:34 UTC (permalink / raw)
  To: 'Jaegeuk Kim', 'He YunLei'; +Cc: linux-f2fs-devel

Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Sunday, November 15, 2015 2:27 AM
> To: He YunLei; He YunLei
> Cc: linux-f2fs-devel@lists.sourceforge.net; linux-f2fs-devel@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH] mkfs.f2fs: introduce -b option to support specified fs size
> formating
> 
> Hello,
> 
> On Sat, Nov 14, 2015 at 01:32:29PM +0800, He YunLei wrote:
> > hi,
> >
> > We can specify fs size in function f2fs_parse_options as follow:
> >      if ((optind + 1) < argc) {
> >          /* We have a sector count. */
> >          config.total_sectors = atoll(argv[optind+1]);
> > which one is better?
> 
> Yeah, there is.
> I don't think we need to add redundant options.

Actually, Yes, it's redundant.

But what I try to do is introducing an option what can be used more simply by
users of mkfs.f2fs. That means: 1. user do not need take time to calculate
total sector number of our new fs; 2. It will not make any trouble for the user
who does not know the sector size of storage device.

One more intention here is to fix the mismatch between of parameter passed in
_scratch_mkfs_sized and parameter received in mkfs.f2fs. As one is block size,
and another is sector size.

> 
> >
> > Thanks
> >
> > On 2015/11/10 16:48, Chao Yu wrote:
> > > This patch introduces a new option '-b', with this option user can specify
> > > required fs size for formating. _scratch_mkfs_sized in xfstest is one of
> > > user cases.
> 
> We need to add one for f2fs in xfstest.

Yeah, I'm prepare to previously once this patch can be merged.

> Actually, I have a patch pending in my local xfstest.
> Let me submit that sooner or later. :)

Good, glad to see we can make xfstest supporting mkfs_sized for f2fs. :)

Thanks,

> 
> Thanks,
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-15  6:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10  8:48 [PATCH] mkfs.f2fs: introduce -b option to support specified fs size formating Chao Yu
2015-11-14  5:32 ` He YunLei
2015-11-14 18:27   ` Jaegeuk Kim
2015-11-15  6:34     ` Chao Yu

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.