patch ext34-ensure-do_split-leaves-enough-free-space-in-both-blocks.patch queued to -stable tree

2007-09-21 Thread gregkh

This is a note to let you know that we have just queued up the patch titled

 Subject: ext34: ensure do_split leaves enough free space in both blocks

to the 2.6.22-stable tree.  Its filename is

 ext34-ensure-do_split-leaves-enough-free-space-in-both-blocks.patch

A git repo of this tree can be found at 

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary


From [EMAIL PROTECTED] Tue Sep 18 22:47:15 2007
From: Eric Sandeen [EMAIL PROTECTED]
Date: Tue, 18 Sep 2007 22:46:42 -0700
Subject: ext34: ensure do_split leaves enough free space in both blocks
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], 
[EMAIL PROTECTED], linux-ext4@vger.kernel.org, [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]

From: Eric Sandeen [EMAIL PROTECTED]

commit ef2b02d3e617cb0400eedf2668f86215e1b0e6af in mainline.

The do_split() function for htree dir blocks is intended to split a leaf
block to make room for a new entry.  It sorts the entries in the original
block by hash value, then moves the last half of the entries to the new
block - without accounting for how much space this actually moves.  (IOW,
it moves half of the entry *count* not half of the entry *space*).  If by
chance we have both large  small entries, and we move only the smallest
entries, and we have a large new entry to insert, we may not have created
enough space for it.

The patch below stores each record size when calculating the dx_map, and
then walks the hash-sorted dx_map, calculating how many entries must be
moved to more evenly split the existing entries between the old block and
the new block, guaranteeing enough space for the new entry.

The dx_map offs member is reduced to u16 so that the overall map size
does not change - it is temporarily stored at the end of the new block, and
if it grows too large it may be overwritten.  By making offs and size both
u16, we won't grow the map size.

Also add a few comments to the functions involved.

This fixes the testcase reported by [EMAIL PROTECTED] on the
linux-ext4 list, ext3 dir_index causes an error

Thanks to Andreas Dilger for discussing the problem  solution with me.

Signed-off-by: Eric Sandeen [EMAIL PROTECTED]
Signed-off-by: Andreas Dilger [EMAIL PROTECTED]
Tested-by: Junjiro Okajima [EMAIL PROTECTED]
Cc: Theodore Ts'o [EMAIL PROTECTED]
Cc: ext4 linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]

--- 
a/fs/ext3/namei.c~ext34-ensure-do_split-leaves-enough-free-space-in-both-blocks
+++ a/fs/ext3/namei.c
@@ -140,7 +140,8 @@ struct dx_frame
 struct dx_map_entry
 {
u32 hash;
-   u32 offs;
+   u16 offs;
+   u16 size;
 };
 
 #ifdef CONFIG_EXT3_INDEX
@@ -697,6 +698,10 @@ errout:
  * Directory block splitting, compacting
  */
 
+/*
+ * Create map of hash values, offsets, and sizes, stored at end of block.
+ * Returns number of entries mapped.
+ */
 static int dx_make_map (struct ext3_dir_entry_2 *de, int size,
struct dx_hash_info *hinfo, struct dx_map_entry 
*map_tail)
 {
@@ -710,7 +715,8 @@ static int dx_make_map (struct ext3_dir_
ext3fs_dirhash(de-name, de-name_len, h);
map_tail--;
map_tail-hash = h.hash;
-   map_tail-offs = (u32) ((char *) de - base);
+   map_tail-offs = (u16) ((char *) de - base);
+   map_tail-size = le16_to_cpu(de-rec_len);
count++;
cond_resched();
}
@@ -720,6 +726,7 @@ static int dx_make_map (struct ext3_dir_
return count;
 }
 
+/* Sort map by hash value */
 static void dx_sort_map (struct dx_map_entry *map, unsigned count)
 {
 struct dx_map_entry *p, *q, *top = map + count - 1;
@@ -1117,6 +1124,10 @@ static inline void ext3_set_de_type(stru
 }
 
 #ifdef CONFIG_EXT3_INDEX
+/*
+ * Move count entries from end of map between two memory locations.
+ * Returns pointer to last entry moved.
+ */
 static struct ext3_dir_entry_2 *
 dx_move_dirents(char *from, char *to, struct dx_map_entry *map, int count)
 {
@@ -1135,6 +1146,10 @@ dx_move_dirents(char *from, char *to, st
return (struct ext3_dir_entry_2 *) (to - rec_len);
 }
 
+/*
+ * Compact each dir entry in the range to the minimal rec_len.
+ * Returns pointer to last entry in range.
+ */
 static struct ext3_dir_entry_2* dx_pack_dirents(char *base, int size)
 {
struct ext3_dir_entry_2 *next, *to, *prev, *de = (struct 
ext3_dir_entry_2 *) base;
@@ -1157,6 +1172,11 @@ static struct ext3_dir_entry_2* dx_pack_
return prev;
 }
 
+/*
+ * Split a full leaf block to make room for a new dir entry.
+ * Allocate a new block, and move entries so that they are approx. equally 
full.
+ * Returns pointer to de in block into which the new entry will be inserted.
+ */
 

patch ext4_ext_put_in_cache-uses-__u32-to-receive-physical-block-number.patch queued to -stable tree

2007-08-07 Thread gregkh

This is a note to let you know that we have just queued up the patch titled

 Subject: ext4_ext_put_in_cache uses __u32 to receive physical block 
number

to the 2.6.22-stable tree.  Its filename is

 ext4_ext_put_in_cache-uses-__u32-to-receive-physical-block-number.patch

A git repo of this tree can be found at 

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary


From [EMAIL PROTECTED] Tue Jul 31 00:48:13 2007
From: Mingming Cao [EMAIL PROTECTED]
Date: Tue, 31 Jul 2007 00:37:46 -0700
Subject: ext4_ext_put_in_cache uses __u32 to receive physical block number
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], linux-ext4@vger.kernel.org, [EMAIL PROTECTED], [EMAIL 
PROTECTED], [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]


From: Mingming Cao [EMAIL PROTECTED]

Yan Zheng wrote:

 I think I found a bug in ext4/extents.c, ext4_ext_put_in_cache uses
 __u32 to receive physical block number.  ext4_ext_put_in_cache is
 used in ext4_ext_get_blocks, it sets ext4 inode's extent cache
 according most recently tree lookup (higher 16 bits of saved physical
 block number are always zero). when serving a mapping request,
 ext4_ext_get_blocks first check whether the logical block is in
 inode's extent cache. if the logical block is in the cache and the
 cached region isn't a gap, ext4_ext_get_blocks gets physical block
 number by using cached region's physical block number and offset in
 the cached region.  as described above, ext4_ext_get_blocks may
 return wrong result when there are physical block numbers bigger than
 0x.


You are right.  Thanks for reporting this!

Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Cc: Yan Zheng [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]

--- a/fs/ext4/extents.c~ext4_ext_put_in_cache-uses-__u32-to-receive-physical
+++ a/fs/ext4/extents.c
@@ -1544,7 +1544,7 @@ int ext4_ext_walk_space(struct inode *in
 
 static void
 ext4_ext_put_in_cache(struct inode *inode, __u32 block,
-   __u32 len, __u32 start, int type)
+   __u32 len, ext4_fsblk_t start, int type)
 {
struct ext4_ext_cache *cex;
BUG_ON(len == 0);
_

___
stable mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/stable



Patches currently in stable-queue which might be from [EMAIL PROTECTED] are

queue-2.6.22/ext4_ext_put_in_cache-uses-__u32-to-receive-physical-block-number.patch
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


patch jbd-commit-fix-transaction-dropping.patch queued to -stable tree

2007-08-07 Thread gregkh

This is a note to let you know that we have just queued up the patch titled

 Subject: jbd commit: fix transaction dropping

to the 2.6.22-stable tree.  Its filename is

 jbd-commit-fix-transaction-dropping.patch

A git repo of this tree can be found at 

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary


From [EMAIL PROTECTED] Sun Jul 15 23:37:47 2007
From: Jan Kara [EMAIL PROTECTED]
Date: Sun, 15 Jul 2007 23:37:18 -0700
Subject: jbd commit: fix transaction dropping
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], 
linux-ext4@vger.kernel.org, [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]


From: Jan Kara [EMAIL PROTECTED]

We have to check that also the second checkpoint list is non-empty before
dropping the transaction.

Signed-off-by: Jan Kara [EMAIL PROTECTED]
Cc: Chuck Ebbert [EMAIL PROTECTED]
Cc: Kirill Korotaev [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]

diff -puN fs/jbd/commit.c~jbd-commit-fix-transaction-dropping fs/jbd/commit.c
--- a/fs/jbd/commit.c~jbd-commit-fix-transaction-dropping
+++ a/fs/jbd/commit.c
@@ -887,7 +887,8 @@ restart_loop:
journal-j_committing_transaction = NULL;
spin_unlock(journal-j_state_lock);
 
-   if (commit_transaction-t_checkpoint_list == NULL) {
+   if (commit_transaction-t_checkpoint_list == NULL 
+   commit_transaction-t_checkpoint_io_list == NULL) {
__journal_drop_transaction(journal, commit_transaction);
} else {
if (journal-j_checkpoint_transactions == NULL) {
_

___
stable mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/stable



Patches currently in stable-queue which might be from [EMAIL PROTECTED] are

queue-2.6.22/jbd-commit-fix-transaction-dropping.patch
queue-2.6.22/jbd2-commit-fix-transaction-dropping.patch
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


patch jbd2-commit-fix-transaction-dropping.patch queued to -stable tree

2007-08-07 Thread gregkh

This is a note to let you know that we have just queued up the patch titled

 Subject: jbd2 commit: fix transaction dropping

to the 2.6.22-stable tree.  Its filename is

 jbd2-commit-fix-transaction-dropping.patch

A git repo of this tree can be found at 

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary


From [EMAIL PROTECTED] Sun Jul 15 23:37:38 2007
From: Jan Kara [EMAIL PROTECTED]
Date: Sun, 15 Jul 2007 23:37:20 -0700
Subject: jbd2 commit: fix transaction dropping
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], 
linux-ext4@vger.kernel.org, [EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]


From: Jan Kara [EMAIL PROTECTED]

We have to check that also the second checkpoint list is non-empty before
dropping the transaction.

Signed-off-by: Jan Kara [EMAIL PROTECTED]
Cc: Chuck Ebbert [EMAIL PROTECTED]
Cc: Kirill Korotaev [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]

diff -puN fs/jbd2/commit.c~jbd2-commit-fix-transaction-dropping fs/jbd2/commit.c
--- a/fs/jbd2/commit.c~jbd2-commit-fix-transaction-dropping
+++ a/fs/jbd2/commit.c
@@ -896,7 +896,8 @@ restart_loop:
journal-j_committing_transaction = NULL;
spin_unlock(journal-j_state_lock);
 
-   if (commit_transaction-t_checkpoint_list == NULL) {
+   if (commit_transaction-t_checkpoint_list == NULL 
+   commit_transaction-t_checkpoint_io_list == NULL) {
__jbd2_journal_drop_transaction(journal, commit_transaction);
} else {
if (journal-j_checkpoint_transactions == NULL) {
_

___
stable mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/stable



Patches currently in stable-queue which might be from [EMAIL PROTECTED] are

queue-2.6.22/jbd-commit-fix-transaction-dropping.patch
queue-2.6.22/jbd2-commit-fix-transaction-dropping.patch
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


patch revert-retries-in-ext3_prepare_write-violate-ordering-requirements.patch queued to -stable tree

2007-04-11 Thread gregkh

This is a note to let you know that we have just queued up the patch titled

 Subject: revert retries in ext3_prepare_write() violate ordering 
requirements

to the 2.6.20-stable tree.  Its filename is

 revert-retries-in-ext3_prepare_write-violate-ordering-requirements.patch

A git repo of this tree can be found at 

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary


From [EMAIL PROTECTED] Sun Apr  1 23:51:13 2007
From: Andrew Morton [EMAIL PROTECTED]
Date: Sun, 01 Apr 2007 23:49:43 -0700
Subject: revert retries in ext3_prepare_write() violate ordering requirements
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], 
[EMAIL PROTECTED], [EMAIL PROTECTED], linux-ext4@vger.kernel.org, [EMAIL 
PROTECTED]
Message-ID: [EMAIL PROTECTED]


From: Andrew Morton [EMAIL PROTECTED]

Revert e92a4d595b464c4aae64be39ca61a9ffe9c8b278.

Dmitry points out

When we block_prepare_write() failed while ext3_prepare_write() we jump to
 failure label and call ext3_prepare_failure() witch search last mapped bh
 and invoke commit_write untill it.  This is wrong!!  because some bh from
 begining to the last mapped bh may be not uptodate.  As a result we commit to
 disk not uptodate page content witch contains garbage from previous usage.

and

Unexpected file size increasing.

   Call trace the same as it was in first issue but result is different. 
   For example we have file with i_size is zero.  we want write two blocks ,
   but fs has only one free block.

   -ext3_prepare_write(...from == 0, to == 2048)
 retry:
 -block_prepare_write() == -ENOSPC# we failed but allocated one block here.
 -ext3_prepare_failure()
   -commit_write( from == 0, to == 1024) # after this i_size becomes 1024 
:)
 if (ret == -ENOSPC  ext3_should_retry_alloc(inode-i_sb, retries))
goto retry;

   Finally when all retries will be spended ext3_prepare_failure return
   -ENOSPC, but i_size was increased and later block trimm procedures can't
   help here.

We don't appear to have the horsepower to fix these issues, so let's put
things back the way they were for now.

Cc: Kirill Korotaev [EMAIL PROTECTED]
Cc: Ingo Molnar [EMAIL PROTECTED]
Cc: Ken Chen [EMAIL PROTECTED]
Cc: Andrey Savochkin [EMAIL PROTECTED]
Cc: linux-ext4@vger.kernel.org
Cc: Dmitriy Monakhov [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]


--- 
a/fs/ext3/inode.c~revert-retries-in-ext3_prepare_write-violate-ordering-requirements
+++ a/fs/ext3/inode.c
@@ -1148,102 +1148,37 @@ static int do_journal_get_write_access(h
return ext3_journal_get_write_access(handle, bh);
 }
 
-/*
- * The idea of this helper function is following:
- * if prepare_write has allocated some blocks, but not all of them, the
- * transaction must include the content of the newly allocated blocks.
- * This content is expected to be set to zeroes by block_prepare_write().
- * 2006/10/14  SAW
- */
-static int ext3_prepare_failure(struct file *file, struct page *page,
-   unsigned from, unsigned to)
-{
-   struct address_space *mapping;
-   struct buffer_head *bh, *head, *next;
-   unsigned block_start, block_end;
-   unsigned blocksize;
-   int ret;
-   handle_t *handle = ext3_journal_current_handle();
-
-   mapping = page-mapping;
-   if (ext3_should_writeback_data(mapping-host)) {
-   /* optimization: no constraints about data */
-skip:
-   return ext3_journal_stop(handle);
-   }
-
-   head = page_buffers(page);
-   blocksize = head-b_size;
-   for (   bh = head, block_start = 0;
-   bh != head || !block_start;
-   block_start = block_end, bh = next)
-   {
-   next = bh-b_this_page;
-   block_end = block_start + blocksize;
-   if (block_end = from)
-   continue;
-   if (block_start = to) {
-   block_start = to;
-   break;
-   }
-   if (!buffer_mapped(bh))
-   /* prepare_write failed on this bh */
-   break;
-   if (ext3_should_journal_data(mapping-host)) {
-   ret = do_journal_get_write_access(handle, bh);
-   if (ret) {
-   ext3_journal_stop(handle);
-   return ret;
-   }
-   }
-   /*
-* block_start here becomes the first block where the current iteration
-* of prepare_write failed.
-*/
-   }
-   if (block_start = from)
-   goto skip;
-
-   /* commit allocated and zeroed buffers */
-   return mapping-a_ops-commit_write(file, page, from, block_start);
-}
-
 static int ext3_prepare_write(struct file *file, struct page *page,