All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] ocfs2: Add a missing journal credit in ocfs2_link_credits() -v2
@ 2011-10-19  1:34 xiaowei.hu at oracle.com
  2011-11-17  9:52 ` Joel Becker
  0 siblings, 1 reply; 2+ messages in thread
From: xiaowei.hu at oracle.com @ 2011-10-19  1:34 UTC (permalink / raw)
  To: ocfs2-devel

From: Xiaowei.Hu <xiaowei.hu@oracle.com>

With indexed_dir enabled, ocfs2 maintains a list of dirblocks having
space.

The credit calculation in ocfs2_link_credits() did not correctly account
for adding an entry that exactly fills a dirblock that triggers removing
that dirblock by changing the pointer in the previous block in the list.
The credit calculation did not account for that previous block.

To expose, do:

mkfs.ocfs2 -b 512 -M local /dev/sdX
mount /dev/sdX /ocfs2
mkdir /ocfs2/linkdir
touch /ocfs2/linkdir/file1
for i in `seq 1 29` ; do link /ocfs2/linkdir/file1
/ocfs2/linkdir/linklinklinklinklinklink$i; done
rm -f /ocfs2/linkdir/linklinklinklinklinklink10
sleep 8
link /ocfs2/linkdir/file1
/ocfs2/linkdir/linklinklinklinklinklinkaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Note:
The link names have been crafted for a 512 byte blocksize. Reproducing
with a larger blocksize will require longer (or more) links. The sleep
is important. We want jbd2 to commit the transaction so that the missing
block does not piggy back on account of the previous transaction.

Signed-off-by: XiaoweiHu <xiaowei.hu@oracle.com>
Reviewed-by: WengangWang <wen.gang.wang@oracle.com>
Reviewed-by: Sunil.Mushran <sunil.mushran@oracle.com>
---
 fs/ocfs2/journal.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 68cf2f6..a3385b6 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -441,10 +441,11 @@ static inline int ocfs2_mknod_credits(struct super_block *sb, int is_dir,
 #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2)
 
 /* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota
- * update on dir + index leaf + dx root update for free list */
+ * update on dir + index leaf + dx root update for free list +
+ * previous dirblock update in the free list */
 static inline int ocfs2_link_credits(struct super_block *sb)
 {
-	return 2*OCFS2_INODE_UPDATE_CREDITS + 3 +
+	return 2*OCFS2_INODE_UPDATE_CREDITS + 4 +
 	       ocfs2_quota_trans_credits(sb);
 }
 
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Ocfs2-devel] [PATCH] ocfs2: Add a missing journal credit in ocfs2_link_credits() -v2
  2011-10-19  1:34 [Ocfs2-devel] [PATCH] ocfs2: Add a missing journal credit in ocfs2_link_credits() -v2 xiaowei.hu at oracle.com
@ 2011-11-17  9:52 ` Joel Becker
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Becker @ 2011-11-17  9:52 UTC (permalink / raw)
  To: ocfs2-devel

On Wed, Oct 19, 2011 at 09:34:19AM +0800, xiaowei.hu at oracle.com wrote:
> From: Xiaowei.Hu <xiaowei.hu@oracle.com>
> 
> With indexed_dir enabled, ocfs2 maintains a list of dirblocks having
> space.
> 
> The credit calculation in ocfs2_link_credits() did not correctly account
> for adding an entry that exactly fills a dirblock that triggers removing
> that dirblock by changing the pointer in the previous block in the list.
> The credit calculation did not account for that previous block.
> 
> To expose, do:
> 
> mkfs.ocfs2 -b 512 -M local /dev/sdX
> mount /dev/sdX /ocfs2
> mkdir /ocfs2/linkdir
> touch /ocfs2/linkdir/file1
> for i in `seq 1 29` ; do link /ocfs2/linkdir/file1
> /ocfs2/linkdir/linklinklinklinklinklink$i; done
> rm -f /ocfs2/linkdir/linklinklinklinklinklink10
> sleep 8
> link /ocfs2/linkdir/file1
> /ocfs2/linkdir/linklinklinklinklinklinkaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> 
> Note:
> The link names have been crafted for a 512 byte blocksize. Reproducing
> with a larger blocksize will require longer (or more) links. The sleep
> is important. We want jbd2 to commit the transaction so that the missing
> block does not piggy back on account of the previous transaction.
> 
> Signed-off-by: XiaoweiHu <xiaowei.hu@oracle.com>
> Reviewed-by: WengangWang <wen.gang.wang@oracle.com>
> Reviewed-by: Sunil.Mushran <sunil.mushran@oracle.com>

	This patch is now in the 'fixes' branch of ocfs2.git.

Joel

> ---
>  fs/ocfs2/journal.h |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
> index 68cf2f6..a3385b6 100644
> --- a/fs/ocfs2/journal.h
> +++ b/fs/ocfs2/journal.h
> @@ -441,10 +441,11 @@ static inline int ocfs2_mknod_credits(struct super_block *sb, int is_dir,
>  #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2)
>  
>  /* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota
> - * update on dir + index leaf + dx root update for free list */
> + * update on dir + index leaf + dx root update for free list +
> + * previous dirblock update in the free list */
>  static inline int ocfs2_link_credits(struct super_block *sb)
>  {
> -	return 2*OCFS2_INODE_UPDATE_CREDITS + 3 +
> +	return 2*OCFS2_INODE_UPDATE_CREDITS + 4 +
>  	       ocfs2_quota_trans_credits(sb);
>  }
>  
> -- 
> 1.7.4.4
> 
> 
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-devel

-- 

"I inject pure kryptonite into my brain.
 It improves my kung fu, and it eases the pain."

			http://www.jlbec.org/
			jlbec at evilplan.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-17  9:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-19  1:34 [Ocfs2-devel] [PATCH] ocfs2: Add a missing journal credit in ocfs2_link_credits() -v2 xiaowei.hu at oracle.com
2011-11-17  9:52 ` Joel Becker

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.