1 From ac60e745d0187b11d9e7f9fcb37e64cc7c02ded0 Mon Sep 17 00:00:00 2001
2 From: Jan Kara <jack@suse.cz>
3 Date: Wed, 17 Jun 2009 19:09:19 +0200
4 Subject: [PATCH 3/6] ocfs2: Initialize blocks allocated to local quota file
6 When we extend local quota file, we should initialize data
7 in newly allocated block. Firstly because on recovery we could
8 parse bogus data, secondly so that block checksums are properly
11 Signed-off-by: Jan Kara <jack@suse.cz>
13 fs/ocfs2/quota_local.c | 98 ++++++++++++++++++++++++++++++++++++++++-------
14 1 files changed, 83 insertions(+), 15 deletions(-)
16 Index: linux-2.6.27-SLE11_BRANCH/fs/ocfs2/quota_local.c
17 ===================================================================
18 --- linux-2.6.27-SLE11_BRANCH.orig/fs/ocfs2/quota_local.c 2009-07-16 13:26:06.000000000 +0200
19 +++ linux-2.6.27-SLE11_BRANCH/fs/ocfs2/quota_local.c 2009-07-16 14:00:23.000000000 +0200
21 struct ocfs2_local_disk_chunk *dchunk;
24 - struct buffer_head *bh = NULL;
25 + struct buffer_head *bh = NULL, *dbh = NULL;
28 /* We are protected by dqio_sem so no locking needed */
31 dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data;
33 - handle = ocfs2_start_trans(OCFS2_SB(sb), 2);
34 + handle = ocfs2_start_trans(OCFS2_SB(sb), 3);
36 status = PTR_ERR(handle);
42 + /* Initialize new block with structures */
43 + down_read(&OCFS2_I(lqinode)->ip_alloc_sem);
44 + status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks + 1,
45 + &p_blkno, NULL, NULL);
46 + up_read(&OCFS2_I(lqinode)->ip_alloc_sem);
51 + dbh = sb_getblk(sb, p_blkno);
57 + ocfs2_set_new_buffer_uptodate(lqinode, dbh);
58 + status = ocfs2_journal_access(handle, lqinode, dbh,
59 + OCFS2_JOURNAL_ACCESS_CREATE);
65 + memset(dbh->b_data, 0, sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE);
67 + status = ocfs2_journal_dirty(handle, dbh);
73 + /* Update local quotafile info */
74 oinfo->dqi_blocks += 2;
76 status = ocfs2_local_write_info(sb, type);
78 ocfs2_commit_trans(OCFS2_SB(sb), handle);
82 kmem_cache_free(ocfs2_qf_chunk_cachep, chunk);
83 return ERR_PTR(status);
86 struct ocfs2_local_disk_chunk *dchunk;
87 int epb = ol_quota_entries_per_block(sb);
88 unsigned int chunk_blocks;
89 + struct buffer_head *bh;
94 @@ -1066,12 +1101,46 @@
98 - handle = ocfs2_start_trans(OCFS2_SB(sb), 2);
100 + /* Get buffer from the just added block */
101 + down_read(&OCFS2_I(lqinode)->ip_alloc_sem);
102 + status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks,
103 + &p_blkno, NULL, NULL);
104 + up_read(&OCFS2_I(lqinode)->ip_alloc_sem);
106 + mlog_errno(status);
109 + bh = sb_getblk(sb, p_blkno);
112 + mlog_errno(status);
115 + ocfs2_set_new_buffer_uptodate(lqinode, bh);
117 + handle = ocfs2_start_trans(OCFS2_SB(sb), 3);
118 if (IS_ERR(handle)) {
119 status = PTR_ERR(handle);
123 + /* Zero created block */
124 + status = ocfs2_journal_access(handle, lqinode, bh,
125 + OCFS2_JOURNAL_ACCESS_CREATE);
127 + mlog_errno(status);
131 + memset(bh->b_data, 0, sb->s_blocksize);
133 + status = ocfs2_journal_dirty(handle, bh);
135 + mlog_errno(status);
138 + /* Update chunk header */
139 status = ocfs2_journal_access(handle, lqinode, chunk->qc_headerbh,
140 OCFS2_JOURNAL_ACCESS_WRITE);
142 @@ -1088,6 +1157,7 @@
146 + /* Update file header */
148 status = ocfs2_local_write_info(sb, type);