]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Allow truncate to discard unmapped buffers
authorAndrew Morton <akpm@zip.com.au>
Sun, 5 May 2002 08:09:33 +0000 (01:09 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 5 May 2002 08:09:33 +0000 (01:09 -0700)
The buffer state "uptodate, dirty, unmapped" is legal.  It occurs when
a mapped page with attached buffers which is over a hole is dirtied.

So discard_buffer() needs to be able to discard those buffers as well;
otherwise the page ends up clean, with dirty buffers and is unfreeable.

fs/buffer.c
fs/jbd/transaction.c

index fd2ce5beafacf42241a2911e01c5c6baf2f65984..74674c70dc04e87793a03cbed421b8486adbe96e 100644 (file)
@@ -1091,17 +1091,15 @@ EXPORT_SYMBOL(set_bh_page);
 /*
  * Called when truncating a buffer on a page completely.
  */
-static void discard_buffer(struct buffer_head * bh)
+static /* inline */ void discard_buffer(struct buffer_head * bh)
 {
-       if (buffer_mapped(bh)) {
-               clear_buffer_dirty(bh);
-               lock_buffer(bh);
-               bh->b_bdev = NULL;
-               clear_buffer_mapped(bh);
-               clear_buffer_req(bh);
-               clear_buffer_new(bh);
-               unlock_buffer(bh);
-       }
+       lock_buffer(bh);
+       clear_buffer_dirty(bh);
+       bh->b_bdev = NULL;
+       clear_buffer_mapped(bh);
+       clear_buffer_req(bh);
+       clear_buffer_new(bh);
+       unlock_buffer(bh);
 }
 
 /**
index d0a1518729e5f344e571a389c7be93fbe4e9cb7a..47a4914b7e9dd9105dde8fa39d4e9b0a7f03a351 100644 (file)
@@ -1587,7 +1587,7 @@ static int __journal_try_to_free_buffer(struct buffer_head *bh,
                goto out;
        }
 
-       if (!buffer_uptodate(bh))
+       if (!buffer_uptodate(bh))       /* AKPM: why? */
                goto out;
 
        if (jh->b_next_transaction != 0)
@@ -1775,9 +1775,6 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
 
        BUFFER_TRACE(bh, "entry");
 
-       if (!buffer_mapped(bh))
-               return 1;
-
        /* It is safe to proceed here without the
         * journal_datalist_spinlock because the buffers cannot be
         * stolen by try_to_free_buffers as long as we are holding the