super.c (1420c4a549bf28ffddbed827d61fb3d4d2132ddb) super.c (67c0f556302cfcdb5b5fb7933afa08cb1de75b36)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/ext4/super.c
4 *
5 * Copyright (C) 1992, 1993, 1994, 1995
6 * Remy Card (card@masi.ibp.fr)
7 * Laboratoire MASI - Institut Blaise Pascal
8 * Universite Pierre et Marie Curie (Paris VI)

--- 145 unchanged lines hidden (view full) ---

154 .kill_sb = kill_block_super,
155 .fs_flags = FS_REQUIRES_DEV,
156};
157MODULE_ALIAS_FS("ext3");
158MODULE_ALIAS("ext3");
159#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
160
161
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/ext4/super.c
4 *
5 * Copyright (C) 1992, 1993, 1994, 1995
6 * Remy Card (card@masi.ibp.fr)
7 * Laboratoire MASI - Institut Blaise Pascal
8 * Universite Pierre et Marie Curie (Paris VI)

--- 145 unchanged lines hidden (view full) ---

154 .kill_sb = kill_block_super,
155 .fs_flags = FS_REQUIRES_DEV,
156};
157MODULE_ALIAS_FS("ext3");
158MODULE_ALIAS("ext3");
159#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
160
161
162static inline void __ext4_read_bh(struct buffer_head *bh, int op_flags,
162static inline void __ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
163 bh_end_io_t *end_io)
164{
165 /*
166 * buffer's verified bit is no longer valid after reading from
167 * disk again due to write out error, clear it to make sure we
168 * recheck the buffer contents.
169 */
170 clear_buffer_verified(bh);
171
172 bh->b_end_io = end_io ? end_io : end_buffer_read_sync;
173 get_bh(bh);
174 submit_bh(REQ_OP_READ | op_flags, bh);
175}
176
163 bh_end_io_t *end_io)
164{
165 /*
166 * buffer's verified bit is no longer valid after reading from
167 * disk again due to write out error, clear it to make sure we
168 * recheck the buffer contents.
169 */
170 clear_buffer_verified(bh);
171
172 bh->b_end_io = end_io ? end_io : end_buffer_read_sync;
173 get_bh(bh);
174 submit_bh(REQ_OP_READ | op_flags, bh);
175}
176
177void ext4_read_bh_nowait(struct buffer_head *bh, int op_flags,
177void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
178 bh_end_io_t *end_io)
179{
180 BUG_ON(!buffer_locked(bh));
181
182 if (ext4_buffer_uptodate(bh)) {
183 unlock_buffer(bh);
184 return;
185 }
186 __ext4_read_bh(bh, op_flags, end_io);
187}
188
178 bh_end_io_t *end_io)
179{
180 BUG_ON(!buffer_locked(bh));
181
182 if (ext4_buffer_uptodate(bh)) {
183 unlock_buffer(bh);
184 return;
185 }
186 __ext4_read_bh(bh, op_flags, end_io);
187}
188
189int ext4_read_bh(struct buffer_head *bh, int op_flags, bh_end_io_t *end_io)
189int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags, bh_end_io_t *end_io)
190{
191 BUG_ON(!buffer_locked(bh));
192
193 if (ext4_buffer_uptodate(bh)) {
194 unlock_buffer(bh);
195 return 0;
196 }
197
198 __ext4_read_bh(bh, op_flags, end_io);
199
200 wait_on_buffer(bh);
201 if (buffer_uptodate(bh))
202 return 0;
203 return -EIO;
204}
205
190{
191 BUG_ON(!buffer_locked(bh));
192
193 if (ext4_buffer_uptodate(bh)) {
194 unlock_buffer(bh);
195 return 0;
196 }
197
198 __ext4_read_bh(bh, op_flags, end_io);
199
200 wait_on_buffer(bh);
201 if (buffer_uptodate(bh))
202 return 0;
203 return -EIO;
204}
205
206int ext4_read_bh_lock(struct buffer_head *bh, int op_flags, bool wait)
206int ext4_read_bh_lock(struct buffer_head *bh, blk_opf_t op_flags, bool wait)
207{
208 if (trylock_buffer(bh)) {
209 if (wait)
210 return ext4_read_bh(bh, op_flags, NULL);
211 ext4_read_bh_nowait(bh, op_flags, NULL);
212 return 0;
213 }
214 if (wait) {

--- 7 unchanged lines hidden (view full) ---

222
223/*
224 * This works like __bread_gfp() except it uses ERR_PTR for error
225 * returns. Currently with sb_bread it's impossible to distinguish
226 * between ENOMEM and EIO situations (since both result in a NULL
227 * return.
228 */
229static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb,
207{
208 if (trylock_buffer(bh)) {
209 if (wait)
210 return ext4_read_bh(bh, op_flags, NULL);
211 ext4_read_bh_nowait(bh, op_flags, NULL);
212 return 0;
213 }
214 if (wait) {

--- 7 unchanged lines hidden (view full) ---

222
223/*
224 * This works like __bread_gfp() except it uses ERR_PTR for error
225 * returns. Currently with sb_bread it's impossible to distinguish
226 * between ENOMEM and EIO situations (since both result in a NULL
227 * return.
228 */
229static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb,
230 sector_t block, int op_flags,
231 gfp_t gfp)
230 sector_t block,
231 blk_opf_t op_flags, gfp_t gfp)
232{
233 struct buffer_head *bh;
234 int ret;
235
236 bh = sb_getblk_gfp(sb, block, gfp);
237 if (bh == NULL)
238 return ERR_PTR(-ENOMEM);
239 if (ext4_buffer_uptodate(bh))
240 return bh;
241
242 ret = ext4_read_bh_lock(bh, REQ_META | op_flags, true);
243 if (ret) {
244 put_bh(bh);
245 return ERR_PTR(ret);
246 }
247 return bh;
248}
249
250struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block,
232{
233 struct buffer_head *bh;
234 int ret;
235
236 bh = sb_getblk_gfp(sb, block, gfp);
237 if (bh == NULL)
238 return ERR_PTR(-ENOMEM);
239 if (ext4_buffer_uptodate(bh))
240 return bh;
241
242 ret = ext4_read_bh_lock(bh, REQ_META | op_flags, true);
243 if (ret) {
244 put_bh(bh);
245 return ERR_PTR(ret);
246 }
247 return bh;
248}
249
250struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block,
251 int op_flags)
251 blk_opf_t op_flags)
252{
253 return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE);
254}
255
256struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
257 sector_t block)
258{
259 return __ext4_sb_bread_gfp(sb, block, 0, 0);

--- 6890 unchanged lines hidden ---
252{
253 return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE);
254}
255
256struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
257 sector_t block)
258{
259 return __ext4_sb_bread_gfp(sb, block, 0, 0);

--- 6890 unchanged lines hidden ---