* [PATCH] mkfs: support passing in the number of sectors to use
@ 2014-06-12 4:55 JP Abgrall
0 siblings, 0 replies; only message in thread
From: JP Abgrall @ 2014-06-12 4:55 UTC (permalink / raw)
To: linux-f2fs-devel
Adds the optional sectors count:
mkfs.f2fs [options] device [sectors]
Change-Id: I3ac83121576574bda074140ffa60195a2bc9947b
---
lib/libf2fs.c | 7 +++++++
mkfs/f2fs_format_main.c | 13 ++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index c1e0b0e..7df275c 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -354,6 +354,7 @@ int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len)
*/
void f2fs_init_configuration(struct f2fs_configuration *c)
{
+ c->total_sectors = 0;
c->sector_size = DEFAULT_SECTOR_SIZE;
c->sectors_per_blk = DEFAULT_SECTORS_PER_BLOCK;
c->blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
@@ -430,6 +431,7 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
uint32_t sector_size;
struct stat stat_buf;
struct hd_geometry geom;
+ u_int64_t wanted_total_sectors = c->total_sectors;
fd = open(c->device_name, O_RDWR);
if (fd < 0) {
@@ -472,7 +474,12 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
MSG(0, "\tError: Volume type is not supported!!!\n");
return -1;
}
+ if (wanted_total_sectors && wanted_total_sectors < c->total_sectors) {
+ MSG(0, "Info: total device sectors = %"PRIu64" (in 512bytes)\n",
+ c->total_sectors);
+ c->total_sectors = wanted_total_sectors;
+ }
MSG(0, "Info: sector size = %u\n", c->sector_size);
MSG(0, "Info: total sectors = %"PRIu64" (in 512bytes)\n",
c->total_sectors);
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index cee640a..2b6c195 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -26,7 +26,7 @@ extern struct f2fs_configuration config;
static void mkfs_usage()
{
- MSG(0, "\nUsage: mkfs.f2fs [options] device\n");
+ MSG(0, "\nUsage: mkfs.f2fs [options] device [sectors]\n");
MSG(0, "[options]:\n");
MSG(0, " -a heap-based allocation [default:1]\n");
MSG(0, " -d debug level [default:0]\n");
@@ -36,6 +36,7 @@ static void mkfs_usage()
MSG(0, " -s # of segments per section [default:1]\n");
MSG(0, " -z # of sections per zone [default:1]\n");
MSG(0, " -t 0: nodiscard, 1: discard [default:1]\n");
+ MSG(0, "sectors: number of sectors. [default: determined by device size]\n");
exit(1);
}
@@ -93,15 +94,21 @@ static void f2fs_parse_options(int argc, char *argv[])
}
}
- if ((optind + 1) != argc) {
+ if (optind >= argc) {
MSG(0, "\tError: Device not specified\n");
mkfs_usage();
}
+ config.device_name = argv[optind];
+
+ if ((optind + 1) < argc) {
+ /* We have a sector count. */
+ config.total_sectors = atoll(argv[optind+1]);
+ MSG(0, "\ttotal_sectors=%lu (%s bytes)\n", config.total_sectors, argv[optind+1]);
+ }
config.reserved_segments =
(2 * (100 / config.overprovision + 1) + 6)
* config.segs_per_sec;
- config.device_name = argv[optind];
}
int main(int argc, char *argv[])
--
2.0.0.526.g5318336
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-06-12 5:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-12 4:55 [PATCH] mkfs: support passing in the number of sectors to use JP Abgrall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).