Return-Path: <bart@samwel.tk>
Received: from localhost (bix [127.0.0.1])
	by localhost.localdomain (8.12.10/8.12.10) with ESMTP id i3QBVXF7015497
	for <akpm@localhost>; Mon, 26 Apr 2004 04:31:33 -0700
Received: from bix [127.0.0.1]
	by localhost with POP3 (fetchmail-6.2.0)
	for akpm@localhost (single-drop); Mon, 26 Apr 2004 04:31:33 -0700 (PDT)
Received: from fire-2.osdl.org (air1.pdx.osdl.net [172.20.0.5])
	by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i3QBTB230137
	for <akpm@mail.gateway.osdl.net>; Mon, 26 Apr 2004 04:29:12 -0700
Received: from samwel.tk (kluizenaar.xs4all.nl [213.84.184.247])
	by fire-2.osdl.org (8.12.8/8.12.8) with ESMTP id i3QBT4ws011068
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO)
	for <akpm@osdl.org>; Mon, 26 Apr 2004 04:29:10 -0700
Received: from localhost ([127.0.0.1] helo=samwel.tk)
	by samwel.tk with esmtp (Exim 4.32)
	id 1BI4ID-00047t-M0; Mon, 26 Apr 2004 13:28:58 +0200
Message-ID: <408CF274.4070502@samwel.tk>
Date: Mon, 26 Apr 2004 13:28:52 +0200
From: Bart Samwel <bart@samwel.tk>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: nl, en-us, en
MIME-Version: 1.0
To: Andrew Morton <akpm@osdl.org>
CC: Micha Feigin <michf@post.tau.ac.il>
Subject: [PATCH] Reiserfs commit default fix
Content-Type: multipart/mixed;
 boundary="------------010106010906020301000604"
X-SA-Exim-Connect-IP: 127.0.0.1
X-SA-Exim-Mail-From: bart@samwel.tk
X-SA-Exim-Scanned: No (on samwel.tk); SAEximRunCond expanded to false
X-MIMEDefang-Filter: osdl$Revision: 1.55 $
X-Scanned-By: MIMEDefang 2.36
X-Spam-Status: No, hits=-4.9 required=1.0 tests=BAYES_00 autolearn=ham 
	version=2.60
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on bix

This is a multi-part message in MIME format.
--------------010106010906020301000604
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi Andrew,

This patch from Micha Feigin fixes some bugs in the earlier reiserfs 
commit default patch. The changelog:

* If you remounted without any commit=NNN option, it would assume 
commit=0 and restore the defaults. This patch makes it leave the current 
state alone if you don't pass commit=NNN.

* Added range check for cast from unsigned long to unsigned int.

--Bart

--------------010106010906020301000604
Content-Type: text/plain;
 name="reiserfs-commit-default.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="reiserfs-commit-default.patch"

diff -ruN linux-2.6.6-rc2-mm1/fs/reiserfs/super.c linux-2.6.6-rc2-mm1-reiserfs_fix/fs/reiserfs/super.c
--- linux-2.6.6-rc2-mm1/fs/reiserfs/super.c	2004-04-26 13:28:42.000000000 +0300
+++ linux-2.6.6-rc2-mm1-reiserfs_fix/fs/reiserfs/super.c	2004-04-26 13:57:30.000000000 +0300
@@ -707,13 +707,13 @@
 
 	if ( c == 'c' ) {
 		char *p = 0;
-		int val = simple_strtoul (arg, &p, 0);
+		unsigned long val = simple_strtoul (arg, &p, 0);
 		/* commit=NNN (time in seconds) */
-		if ( *p != '\0' || val < 0) {
+		if ( *p != '\0' || val >= (unsigned int)-1) {
 			printk ("reiserfs_parse_options: bad value %s\n", arg);
 			return 0;
 		}
-		*commit_max_age = val;
+		*commit_max_age = (unsigned int)val;
 	}
 
 	if ( c == 'w' ) {
@@ -796,7 +796,7 @@
   unsigned long blocks;
   unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
   unsigned long safe_mask = 0;
-  unsigned int commit_max_age = 0;
+  unsigned int commit_max_age = (unsigned int)-1;
 
   rs = SB_DISK_SUPER_BLOCK (s);
 
@@ -818,11 +818,11 @@
    * the bits we're not allowed to change here */
   REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) |  (mount_options & safe_mask);
 
-  if(commit_max_age != 0) {
+  if(commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
     SB_JOURNAL_MAX_COMMIT_AGE(s) = commit_max_age;
     SB_JOURNAL_MAX_TRANS_AGE(s) = commit_max_age;
   }
-  else
+  else if(commit_max_age == 0)
   {
     /* 0 means restore defaults. */
     SB_JOURNAL_MAX_COMMIT_AGE(s) = SB_JOURNAL_DEFAULT_MAX_COMMIT_AGE(s);
@@ -1282,7 +1282,7 @@
     struct reiserfs_transaction_handle th ;
     int old_format = 0;
     unsigned long blocks;
-	unsigned int commit_max_age = 0;
+    unsigned int commit_max_age = 0;
     int jinit_done = 0 ;
     struct reiserfs_iget_args args ;
     struct reiserfs_super_block * rs;

--------------010106010906020301000604--