Skip to contentSkip to conversation

reiserfs: make resize option auto-get new device size

PATCH In review [email protected] 2 participants 3 messages Apr 8, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reiserfs: make resize option auto-get new device size

It's trivial for the resize option to auto-get the underlying device size, while it's harder for the user. I've copied the code from jfs.

Since of the different reiserfs option parser (which does not use the superior match_token used by almost every other filesystem), I've had to use the "resize=auto" and not "resize" option to specify this behaviour. Changing the option parser to the kernel one wouldn't be bad but I've no time to do this cleanup in this moment.

Btw, the mount(8) man page should be updated to include this option. Cc the relevant people, please (I hope I cc'ed the right people).

---

 linux-2.6.11-paolo/fs/reiserfs/super.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)
fs/reiserfs/super.c renamed from fs/reiserfs/super.c~reiserfs-resize-option-like-jfs-auto-get +14 -7
diff -puN fs/reiserfs/super.c~reiserfs-resize-option-like-jfs-auto-get fs/reiserfs/super.c
@@ -889,12 +889,18 @@ static int reiserfs_parse_options (struc
 	    char * p;
 	    
 	    p = NULL;
-	    /* "resize=NNN" */
-	    *blocks = simple_strtoul (arg, &p, 0);
-	    if (*p != '\0') {
-		/* NNN does not look like a number */
-		reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
-		return 0;
+	    /* "resize=NNN" or "resize=auto" */
+
+	    if (!strcmp(arg, "auto")) {
+		    /* From JFS code, to auto-get the size.*/
+		    *blocks = s->s_bdev->bd_inode->i_size >> s->s_blocksize_bits;
+	    } else {
+		    *blocks = simple_strtoul (arg, &p, 0);
+		    if (*p != '\0') {
+			/* NNN does not look like a number */
+			reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
+			return 0;
+		    }
 	    }
 	}
 
@@ -903,7 +909,8 @@ static int reiserfs_parse_options (struc
 		unsigned long val = simple_strtoul (arg, &p, 0);
 		/* commit=NNN (time in seconds) */
 		if ( *p != '\0' || val >= (unsigned int)-1) {
-			reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);			return 0;
+			reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
+			return 0;
 		}
 		*commit_max_age = (unsigned int)val;
 	}

_

#1 lore raw

Hi,

Quoted 11 lines · On Fri, Apr 08, 2005 at 06:55:50AM +0200, [email protected] wrote:

It's trivial for the resize option to auto-get the underlying device size, while it's harder for the user. I've copied the code from jfs.

Since of the different reiserfs option parser (which does not use the superior match_token used by almost every other filesystem), I've had to use the "resize=auto" and not "resize" option to specify this behaviour. Changing the option parser to the kernel one wouldn't be bad but I've no time to do this cleanup in this moment.

do people really need it?

user-level utility reisize_reiserfs, being called w/o size argument, calculates the device size and uses resize mount option with correct value.

Quoted 48 lines

Btw, the mount(8) man page should be updated to include this option. Cc the relevant people, please (I hope I cc'ed the right people).

---

 linux-2.6.11-paolo/fs/reiserfs/super.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff -puN fs/reiserfs/super.c~reiserfs-resize-option-like-jfs-auto-get fs/reiserfs/super.c

fs/reiserfs/super.c renamed from fs/reiserfs/super.c~reiserfs-resize-option-like-jfs-auto-get +14 -7
@@ -889,12 +889,18 @@ static int reiserfs_parse_options (struc
 	    char * p;
 
 	    p = NULL;
-	    /* "resize=NNN" */
-	    *blocks = simple_strtoul (arg, &p, 0);
-	    if (*p != '\0') {
-		/* NNN does not look like a number */
-		reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
-		return 0;
+	    /* "resize=NNN" or "resize=auto" */
+
+	    if (!strcmp(arg, "auto")) {
+		    /* From JFS code, to auto-get the size.*/
+		    *blocks = s->s_bdev->bd_inode->i_size >> s->s_blocksize_bits;
+	    } else {
+		    *blocks = simple_strtoul (arg, &p, 0);
+		    if (*p != '\0') {
+			/* NNN does not look like a number */
+			reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
+			return 0;
+		    }
 	    }
 	}
 
@@ -903,7 +909,8 @@ static int reiserfs_parse_options (struc
 		unsigned long val = simple_strtoul (arg, &p, 0);
 		/* commit=NNN (time in seconds) */
 		if ( *p != '\0' || val >= (unsigned int)-1) {
-			reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);			return 0;
+			reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
+			return 0;
 		}
 		*commit_max_age = (unsigned int)val;
 	}

_

Signature · 1 line
Alex.
#2 lore raw
Quoted 9 lines · Alex Zarochentsev

Hi,

Quoted 6 lines · On Fri, Apr 08, 2005 at 06:55:50AM +0200, [email protected] wrote:

Cc: <[email protected]>, <[email protected]>, <[email protected]>

It's trivial for the resize option to auto-get the underlying device size, while it's harder for the user. I've copied the code from jfs.

Quoted 7 lines
Quoted 5 lines

Since of the different reiserfs option parser (which does not use the superior match_token used by almost every other filesystem), I've had to use the "resize=auto" and not "resize" option to specify this behaviour. Changing the option parser to the kernel one wouldn't be bad but I've no time to do this cleanup in this moment.

do people really need it?

Note we are speaking of 2 lines of code. And there's no point in omitting this.

Quoted 2 lines

user-level utility reisize_reiserfs, being called w/o size argument, calculates the device size and uses resize mount option with correct value.

Yes, I know this. But the old versions (the one shipped on Mdk) didn't work for online resizing (this was verified by me with lots of warnings and a Oops on reiserfs code); in fact, this ability is so new that is not even documented in manpages.

Signature · 3 lines
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade