All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <mason@suse.com>
To: "Philippe Gramoullé" <philippe.gramoulle@mmania.com>
Cc: Oleg Drokin <green@namesys.com>, reiserfs-list@namesys.com
Subject: Re: Oops with in nfsd - 2.4.19-pre6
Date: 31 Oct 2002 15:38:19 -0500	[thread overview]
Message-ID: <1036096699.14984.156.camel@tiny> (raw)
In-Reply-To: <20021029162014.0d9b359f.philippe.gramoulle@mmania.com>

On Tue, 2002-10-29 at 10:20, Philippe Gramoullé wrote:
> 
> FYI,
> 
> This in the log , before the oops :
> 
>  journal-1413: journal_mark_dirty: j_len (1024) is too big
> 
>
Ok, this patch goes on top of the quota patches because that is what
Philippe is currently running.  Merging with the pure kernel is trivial,
so I'll do that later.

Since Philippe is putting this onto production machines, I think he
should wait for someone from namesys to review before using the patch.

The idea is that during boundless operations (creating a hole, and
truncates), the journal code wasn't properly reserving log blocks. 
There are two parts to the fix:

1) always reserve extra log blocks when
reiserfs_transaction_should_end() returns 0

2) always send the correct number of log blocks to
reiserfs_transaction_should_end()

#2 also makes hole creation significantly faster.  Before, it used the
number of blocks logged in the last transaction as the number if will
log in the next one, which means it might try to reserve 300 or so log
blocks.  This would usually force the current transcation to close,
leading to a small transaction and lower performance.

Anyway, here's the patch:

-chris

#
# against 2.4.19 + quota + nesting
#
# when testing for a transaction restart, make sure to bump the number
# of blocks allocated, otherwise by the time you get around to 
# journal_mark_dirty, the blocks might have been used by a different
# writer
#
# when restarting the transaction in reiserfs_get_block and truncates,
# don't use th->t_blocks_allocated as the count for the new transaction.
# It gets incremented as the transation grows during the boundless op,
# and might get very very large.
#
diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
--- a/fs/reiserfs/inode.c	Thu Oct 31 15:21:49 2002
+++ b/fs/reiserfs/inode.c	Thu Oct 31 15:21:49 2002
@@ -232,9 +232,9 @@
 }
 
 /*static*/ void restart_transaction(struct reiserfs_transaction_handle *th,
-				struct inode *inode, struct path *path) {
+				struct inode *inode, struct path *path,
+				int jbegin_count) {
   struct super_block *s = th->t_super ;
-  int len = th->t_blocks_allocated ;
 
   /* we cannot restart while nested */
   if (th->t_refcount > 1) {
@@ -242,8 +242,8 @@
   }
   pathrelse(path) ;
   reiserfs_update_sd(th, inode) ;
-  journal_end(th, s, len) ;
-  journal_begin(th, s, len) ;
+  journal_end(th, s, th->t_blocks_allocated) ;
+  journal_begin(th, s, jbegin_count) ;
   reiserfs_update_inode_transaction(inode) ;
 }
 
@@ -655,7 +655,7 @@
 	    ** some blocks.  releases the path, so we have to go back to
 	    ** research if we succeed on the second try
 	    */
-	    restart_transaction(&th, inode, &path) ; 
+	    restart_transaction(&th, inode, &path, jbegin_count) ; 
 	    repeat = _allocate_block(&th, inode,&allocated_block_nr,tag,create);
 
 	    if (repeat != NO_DISK_SPACE && repeat != QUOTA_EXCEEDED) {
@@ -856,8 +856,8 @@
 	** release the path so that anybody waiting on the path before
 	** ending their transaction will be able to continue.
 	*/
-	if (journal_transaction_should_end(&th, th.t_blocks_allocated)) {
-	  restart_transaction(&th, inode, &path) ; 
+	if (journal_transaction_should_end(&th, jbegin_count)) {
+	  restart_transaction(&th, inode, &path, jbegin_count) ; 
 	}
 	/* inserting indirect pointers for a hole can take a 
 	** long time.  reschedule if needed
diff -Nru a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
--- a/fs/reiserfs/journal.c	Thu Oct 31 15:21:49 2002
+++ b/fs/reiserfs/journal.c	Thu Oct 31 15:21:49 2002
@@ -2011,6 +2011,12 @@
        SB_JOURNAL(th->t_super)->j_cnode_free < (JOURNAL_TRANS_MAX * 3)) { 
     return 1 ;
   }
+  
+  /* we are allowing them to continue in the current transaction, so we
+   * have to bump the blocks allocated now.
+   */
+  th->t_blocks_allocated += new_alloc;
+  SB_JOURNAL(th->t_super)->j_len_alloc += new_alloc ;
   return 0 ;
 }
 
diff -Nru a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
--- a/fs/reiserfs/stree.c	Thu Oct 31 15:21:49 2002
+++ b/fs/reiserfs/stree.c	Thu Oct 31 15:21:49 2002
@@ -1730,6 +1730,7 @@
 	n_new_file_size;/* New file size. */
     int                   n_deleted;      /* Number of deleted or truncated bytes. */
     int retval;
+    int jbegin_count = th->t_blocks_allocated;
 
     if ( ! (S_ISREG(p_s_inode->i_mode) || S_ISDIR(p_s_inode->i_mode) || S_ISLNK(p_s_inode->i_mode)) )
 	return;
@@ -1809,16 +1810,15 @@
 	** sure the file is consistent before ending the current trans
 	** and starting a new one
 	*/
-        if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
-	  int orig_len_alloc = th->t_blocks_allocated ;
+        if (journal_transaction_should_end(th, jbegin_count)) {
 	  decrement_counters_in_path(&s_search_path) ;
 
 	  if (update_timestamps) {
 	      p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME;
 	  } 
 	  reiserfs_update_sd(th, p_s_inode) ;
-	  journal_end(th, p_s_inode->i_sb, orig_len_alloc) ;
-	  journal_begin(th, p_s_inode->i_sb, orig_len_alloc) ;
+	  journal_end(th, p_s_inode->i_sb, th->t_blocks_allocated) ;
+	  journal_begin(th, p_s_inode->i_sb, jbegin_count) ;
 	  reiserfs_update_inode_transaction(p_s_inode) ;
 	}
     } while ( n_file_size > ROUND_UP (n_new_file_size) &&



  parent reply	other threads:[~2002-10-31 20:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-29 14:59 Oops with in nfsd - 2.4.19-pre6 Philippe Gramoullé
2002-10-29 15:14 ` Oleg Drokin
2002-10-29 15:20   ` Philippe Gramoullé
2002-10-29 15:26     ` Oleg Drokin
2002-10-31 20:38     ` Chris Mason [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-10-31 21:08 JP Howard
2002-10-31 21:30 ` Chris Mason
2002-11-01 14:46   ` Christopher Barry
2002-11-12 17:29   ` Philippe Gramoullé
2002-11-13 18:14     ` Chris Mason
2002-11-13 18:40       ` Philippe Gramoullé
2002-11-13 20:23         ` Chris Mason
2002-11-14  2:33           ` Chris Mason
2002-11-14 16:04           ` Philippe Gramoullé
2002-11-14 16:32             ` Chris Mason
2002-11-14 17:41               ` Philippe Gramoullé
2002-11-14 17:46                 ` Chris Mason
2002-10-31 22:12 JP Howard

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=1036096699.14984.156.camel@tiny \
    --to=mason@suse.com \
    --cc=green@namesys.com \
    --cc=philippe.gramoulle@mmania.com \
    --cc=reiserfs-list@namesys.com \
    /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 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.