]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/suse-2.6.27.25/patches.suse/ocfs2-Separate-out-sync-reads-from-ocfs2_read_block.patch
Revert "Move xen patchset to new version's subdir."
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.suse / ocfs2-Separate-out-sync-reads-from-ocfs2_read_block.patch
CommitLineData
00e5a55c
BS
1From: Joel Becker <joel.becker@oracle.com>
2Subject: ocfs2: Separate out sync reads from ocfs2_read_blocks()
3Patch-mainline: 2.6.28
4
5The ocfs2_read_blocks() function currently handles sync reads, cached,
6reads, and sometimes cached reads. We're going to add some
7functionality to it, so first we should simplify it. The uncached,
8synchronous reads are much easer to handle as a separate function, so we
9instroduce ocfs2_read_blocks_sync().
10
11Signed-off-by: Joel Becker <joel.becker@oracle.com>
12Signed-off-by: Mark Fasheh <mfasheh@suse.com>
13---
14 fs/ocfs2/buffer_head_io.c | 84 ++++++++++++++++++++++++++++++++++++++++++++-
15 fs/ocfs2/buffer_head_io.h | 2 +
16 fs/ocfs2/inode.c | 7 +++-
17 fs/ocfs2/journal.c | 5 +--
18 fs/ocfs2/resize.c | 8 ++--
19 5 files changed, 96 insertions(+), 10 deletions(-)
20
21Index: linux-2.6.27/fs/ocfs2/buffer_head_io.c
22===================================================================
23--- linux-2.6.27.orig/fs/ocfs2/buffer_head_io.c
24+++ linux-2.6.27/fs/ocfs2/buffer_head_io.c
25@@ -66,7 +66,7 @@ int ocfs2_write_block(struct ocfs2_super
26 /* remove from dirty list before I/O. */
27 clear_buffer_dirty(bh);
28
29- get_bh(bh); /* for end_buffer_write_sync() */
30+ get_bh(bh); /* for end_buffer_write_sync() */
31 bh->b_end_io = end_buffer_write_sync;
32 submit_bh(WRITE, bh);
33
34@@ -88,6 +88,88 @@ out:
35 return ret;
36 }
37
38+int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
39+ unsigned int nr, struct buffer_head *bhs[])
40+{
41+ int status = 0;
42+ unsigned int i;
43+ struct buffer_head *bh;
44+
45+ if (!nr) {
46+ mlog(ML_BH_IO, "No buffers will be read!\n");
47+ goto bail;
48+ }
49+
50+ for (i = 0 ; i < nr ; i++) {
51+ if (bhs[i] == NULL) {
52+ bhs[i] = sb_getblk(osb->sb, block++);
53+ if (bhs[i] == NULL) {
54+ status = -EIO;
55+ mlog_errno(status);
56+ goto bail;
57+ }
58+ }
59+ bh = bhs[i];
60+
61+ if (buffer_jbd(bh)) {
62+ mlog(ML_ERROR,
63+ "trying to sync read a jbd "
64+ "managed bh (blocknr = %llu), skipping\n",
65+ (unsigned long long)bh->b_blocknr);
66+ continue;
67+ }
68+
69+ if (buffer_dirty(bh)) {
70+ /* This should probably be a BUG, or
71+ * at least return an error. */
72+ mlog(ML_ERROR,
73+ "trying to sync read a dirty "
74+ "buffer! (blocknr = %llu), skipping\n",
75+ (unsigned long long)bh->b_blocknr);
76+ continue;
77+ }
78+
79+ lock_buffer(bh);
80+ if (buffer_jbd(bh)) {
81+ mlog(ML_ERROR,
82+ "block %llu had the JBD bit set "
83+ "while I was in lock_buffer!",
84+ (unsigned long long)bh->b_blocknr);
85+ BUG();
86+ }
87+
88+ clear_buffer_uptodate(bh);
89+ get_bh(bh); /* for end_buffer_read_sync() */
90+ bh->b_end_io = end_buffer_read_sync;
91+ submit_bh(READ, bh);
92+ }
93+
94+ for (i = nr; i > 0; i--) {
95+ bh = bhs[i - 1];
96+
97+ if (buffer_jbd(bh)) {
98+ mlog(ML_ERROR,
99+ "the journal got the buffer while it was "
100+ "locked for io! (blocknr = %llu)\n",
101+ (unsigned long long)bh->b_blocknr);
102+ BUG();
103+ }
104+
105+ wait_on_buffer(bh);
106+ if (!buffer_uptodate(bh)) {
107+ /* Status won't be cleared from here on out,
108+ * so we can safely record this and loop back
109+ * to cleanup the other buffers. */
110+ status = -EIO;
111+ put_bh(bh);
112+ bhs[i - 1] = NULL;
113+ }
114+ }
115+
116+bail:
117+ return status;
118+}
119+
120 int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
121 struct buffer_head *bhs[], int flags,
122 struct inode *inode)
123Index: linux-2.6.27/fs/ocfs2/buffer_head_io.h
124===================================================================
125--- linux-2.6.27.orig/fs/ocfs2/buffer_head_io.h
126+++ linux-2.6.27/fs/ocfs2/buffer_head_io.h
127@@ -46,6 +46,8 @@ int ocfs2_read_blocks(struct ocfs2_super
128 struct buffer_head *bhs[],
129 int flags,
130 struct inode *inode);
131+int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
132+ unsigned int nr, struct buffer_head *bhs[]);
133
134 int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
135 struct buffer_head *bh);
136Index: linux-2.6.27/fs/ocfs2/inode.c
137===================================================================
138--- linux-2.6.27.orig/fs/ocfs2/inode.c
139+++ linux-2.6.27/fs/ocfs2/inode.c
140@@ -460,8 +460,11 @@ static int ocfs2_read_locked_inode(struc
141 }
142 }
143
144- status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0,
145- can_lock ? inode : NULL);
146+ if (can_lock)
147+ status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0,
148+ inode);
149+ else
150+ status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh);
151 if (status < 0) {
152 mlog_errno(status);
153 goto bail;
154Index: linux-2.6.27/fs/ocfs2/journal.c
155===================================================================
156--- linux-2.6.27.orig/fs/ocfs2/journal.c
157+++ linux-2.6.27/fs/ocfs2/journal.c
158@@ -850,9 +850,8 @@ static int ocfs2_force_read_journal(stru
159
160 /* We are reading journal data which should not
161 * be put in the uptodate cache */
162- status = ocfs2_read_blocks(OCFS2_SB(inode->i_sb),
163- p_blkno, p_blocks, bhs, 0,
164- NULL);
165+ status = ocfs2_read_blocks_sync(OCFS2_SB(inode->i_sb),
166+ p_blkno, p_blocks, bhs);
167 if (status < 0) {
168 mlog_errno(status);
169 goto bail;
170Index: linux-2.6.27/fs/ocfs2/resize.c
171===================================================================
172--- linux-2.6.27.orig/fs/ocfs2/resize.c
173+++ linux-2.6.27/fs/ocfs2/resize.c
174@@ -200,7 +200,7 @@ static int update_backups(struct inode *
175 if (cluster > clusters)
176 break;
177
178- ret = ocfs2_read_block(osb, blkno, &backup, 0, NULL);
179+ ret = ocfs2_read_blocks_sync(osb, blkno, 1, &backup);
180 if (ret < 0) {
181 mlog_errno(ret);
182 break;
183@@ -236,8 +236,8 @@ static void ocfs2_update_super_and_backu
184 * update the superblock last.
185 * It doesn't matter if the write failed.
186 */
187- ret = ocfs2_read_block(osb, OCFS2_SUPER_BLOCK_BLKNO,
188- &super_bh, 0, NULL);
189+ ret = ocfs2_read_blocks_sync(osb, OCFS2_SUPER_BLOCK_BLKNO, 1,
190+ &super_bh);
191 if (ret < 0) {
192 mlog_errno(ret);
193 goto out;
194@@ -540,7 +540,7 @@ int ocfs2_group_add(struct inode *inode,
195 goto out_unlock;
196 }
197
198- ret = ocfs2_read_block(osb, input->group, &group_bh, 0, NULL);
199+ ret = ocfs2_read_blocks_sync(osb, input->group, 1, &group_bh);
200 if (ret < 0) {
201 mlog(ML_ERROR, "Can't read the group descriptor # %llu "
202 "from the device.", (unsigned long long)input->group);