reiserfs-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jeffm@suse.com
To: ReiserFS Development List <reiserfs-devel@vger.kernel.org>
Cc: Edward Shishkin <edward.shishkin@gmail.com>
Subject: [patch 4/9] [PATCH] reiserfsprogs: changes for better external journal defaults
Date: Thu, 24 Jan 2008 15:02:30 -0500	[thread overview]
Message-ID: <20080124200337.426568000@suse.com> (raw)
In-Reply-To: 20080124200226.606635000@suse.com

[-- Attachment #1: reiserfsprogs-external-journal-changes.diff --]
[-- Type: text/plain, Size: 5808 bytes --]

 Currently, when presented with an external journal device, reiserfsprogs will
 use the entire device. This is fine when the external device is, say, a
 128 MB NVRAM "disk", but when it is another external partition it can
 cause problems on 32-bit machines and 64-bit machines with limited memory
 capacity.

 This patch does a few things, all related:
 * It changes the default external journal size to be journal_default_size,
   just like the internal size.
 * If an external journal device is larger than the used space, it warns
   the user that they are wasting space.
 * Changes the warning re: journal sizes > default size to be more descriptive.
 * Checks to see if the journal size is larger than the max size. If it is
   an error is issued with a description why and instructions to use -f if
   the action is truly desired.
 * Adds a "force" mode to reiserfs_create_journal()

 This may all sound theoretical, but it actually causes machines to crash. We
 recenly saw a bug report where the user chose an external journal device
 of ~ 8 GB. When journal_init() tried to allocate cnodes, it failed silently
 and then panicked the node when it needed to actually use a cnode. A patch
 to address that issue follows.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 include/reiserfs_lib.h  |    2 +-
 mkreiserfs/mkreiserfs.c |    2 +-
 reiserfscore/journal.c  |   42 ++++++++++++++++++++++++++++++++++--------
 tune/tune.c             |    2 +-
 4 files changed, 37 insertions(+), 11 deletions(-)

--- a/include/reiserfs_lib.h	2004-10-01 12:19:34.000000000 -0400
+++ b/include/reiserfs_lib.h	2008-01-24 13:39:04.000000000 -0500
@@ -346,7 +346,7 @@ int reiserfs_open_journal (reiserfs_fils
 int reiserfs_journal_params_check(reiserfs_filsys_t *fs);
 int reiserfs_create_journal (reiserfs_filsys_t * fs, char * j_filename,
 			     unsigned long offset, unsigned long len, 
-			     int transaction_max_size);
+			     int transaction_max_size, int force);
 int reiserfs_journal_opened (reiserfs_filsys_t *);
 void reiserfs_flush_journal (reiserfs_filsys_t * fs);
 void reiserfs_free_journal (reiserfs_filsys_t * fs);
--- a/mkreiserfs/mkreiserfs.c	2008-01-24 13:39:03.000000000 -0500
+++ b/mkreiserfs/mkreiserfs.c	2008-01-24 13:39:04.000000000 -0500
@@ -702,7 +702,7 @@ int main (int argc, char **argv)
     }
 		
     if (!reiserfs_create_journal (fs, jdevice_name, Offset, Journal_size, 
-	Max_trans_size)) 
+	Max_trans_size, force))
     {
         return 1;
     }
--- a/reiserfscore/journal.c	2004-10-13 09:05:15.000000000 -0400
+++ b/reiserfscore/journal.c	2008-01-24 13:39:04.000000000 -0500
@@ -545,7 +545,8 @@ int reiserfs_create_journal(
     char * j_device,		/* journal device name */
     unsigned long offset,	/* journal offset on the j_device */
     unsigned long len,		/* including journal header */
-    int transaction_max_size)
+    int transaction_max_size,
+    int force)
 {
     struct stat st;
     struct buffer_head * bh;
@@ -596,21 +597,46 @@ int reiserfs_create_journal(
 		    "%lu, blocks on device %lu\n", offset, blocks);
 		return 0;
 	    }
-	    len = blocks - offset;
+	    /* XXX jdm: This can end up being huge and could result
+	     * in an unmountable file system:
+	     * len = blocks - offset; */
+	    len = journal_default_size(fs->fs_super_bh->b_blocknr,
+	                               fs->fs_blocksize) + 1;
+
 	}
 
-	if (len > journal_default_size (fs->fs_super_bh->b_blocknr, 
+	if (!force && len > journal_default_size (fs->fs_super_bh->b_blocknr,
 	    fs->fs_blocksize) + 1) 
 	{
+	    unsigned long journal_max = journal_max_size (fs->fs_super_bh->b_blocknr, fs->fs_blocksize);
 	    fflush(stderr);
 	    
-	    reiserfs_warning (stdout, "NOTE: journal new size %lu is greater "
-		"than default size %lu:\nthis may slow down initializing and "
-		"mounting of the journal. Hope it is ok.\n\n", len, 
-		journal_default_size(fs->fs_super_bh->b_blocknr, 
-		fs->fs_blocksize) + 1);
+	    reiserfs_warning (stdout, "\n*** You've specified a journal "
+	                      "size larger than the default size of "
+	                      "%lu\n*** blocks. This may slow down "
+	                      "journal initialization and mounting "
+	                      "of\n*** the file system.%s",
+	                      journal_default_size(fs->fs_super_bh->b_blocknr, fs->fs_blocksize) + 1,
+	                      len > journal_max ? " " : "\n");
+	    if (len > journal_max)
+		reiserfs_warning (stdout, "On 32-bit systems, and on "
+		                  "64-bit systems with\n*** limited "
+		                  "memory, this may also cause the file "
+		                  "system to be unmountable.\n*** Please "
+		                  "consider using a journal size "
+		                  "<= %lu blocks.\n\nFile system creation "
+				  "failed. You may override this behavior "
+				  "with the -f option.\n", journal_max);
+		    return 0;
 	}
 
+	if (len < blocks)
+		reiserfs_warning (stdout, "\n\n*** Your journal device is %lu "
+		                  "blocks, but your journal is only %lu "
+				  "blocks.\n*** You may want to consider "
+				  "resizing the journal device to avoid "
+				  "wasting space.\n\n", blocks, len);
+
 	if (blocks < offset + len) {
 	    reiserfs_warning (stderr, "reiserfs_create_journal: no enough "
 		"blocks on device %lu, needed %lu\n", blocks, offset + len);
--- a/tune/tune.c	2004-08-19 07:23:57.000000000 -0400
+++ b/tune/tune.c	2008-01-24 13:39:04.000000000 -0500
@@ -710,7 +710,7 @@ int main (int argc, char **argv)
     reiserfs_close_journal (fs);
 
     if (!reiserfs_create_journal (fs, j_new_device_name, Offset,
-				  Journal_size, Max_trans_size)) {
+				  Journal_size, Max_trans_size, Force)) {
 	message ("Could not create new journal");
 	reiserfs_close (fs);
         return 1;



  parent reply	other threads:[~2008-01-24 20:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-24 20:02 [patch 0/9] reiserfsprogs patch queue jeffm
2008-01-24 20:02 ` [patch 1/9] [PATCH] reiserfsprogs: QUIET_MODE should silence credits too jeffm
2008-01-24 20:02 ` [patch 2/9] [PATCH] reiserfsprogs: Warn on block sizes > 4k jeffm
2008-01-24 20:02 ` [patch 3/9] [PATCH] reiserfsprogs: id_map_init off-by-one jeffm
2008-01-24 20:02 ` jeffm [this message]
2008-01-24 20:02 ` [patch 5/9] reiserfsprogs: remove fsck_sleep jeffm
2008-01-24 20:02 ` [patch 6/9] reiserfsprogs: mkfs should use O_EXCL jeffm
2008-01-24 20:02 ` [patch 7/9] [PATCH] reiserfsprogs: enforce 2^32-1 block limit jeffm
2008-01-24 20:02 ` [patch 8/9] [PATCH] reiserfsprogs: Support for file systems > 8 TB jeffm
2008-01-24 20:02 ` [patch 9/9] [PATCH 1/2] reiserfsprogs: add ext3-style mount count and last check expiry for better fsck -a behavior jeffm
2008-01-25 11:01 ` [patch 0/9] reiserfsprogs patch queue Edward Shishkin
2008-01-25 15:45   ` Jeff Mahoney
2008-01-25 15:50     ` Jeff Mahoney
2008-03-24  0:28     ` Edward Shishkin
2008-03-24  2:25       ` Jeff Mahoney
2009-01-09 22:15         ` Edward Shishkin
2009-01-09 23:26           ` Jeff Mahoney
2008-01-25 16:00   ` [PATCH] reiserfsprogs: remove dependency on asm/unaligned.h Jeff Mahoney
2008-02-25  0:58   ` [patch 0/9] reiserfsprogs patch queue Domenico Andreoli
2008-02-25 13:17     ` Edward Shishkin
2008-02-25 16:58       ` Jeff Mahoney
2008-02-25 18:51         ` Edward Shishkin
2008-03-24  0:19         ` Edward Shishkin

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=20080124200337.426568000@suse.com \
    --to=jeffm@suse.com \
    --cc=edward.shishkin@gmail.com \
    --cc=reiserfs-devel@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 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).