Lines Matching defs:bio
14 #include <linux/bio.h>
191 * @bio: The bio
199 static void gfs2_end_log_write(struct bio *bio)
201 struct gfs2_sbd *sdp = bio->bi_private;
206 if (bio->bi_status) {
207 if (!cmpxchg(&sdp->sd_log_error, 0, (int)bio->bi_status))
209 bio->bi_status, sdp->sd_jdesc->jd_jid);
216 bio_for_each_segment_all(bvec, bio, iter_all) {
219 gfs2_end_log_write_bh(sdp, bvec, bio->bi_status);
224 bio_put(bio);
230 * gfs2_log_submit_bio - Submit any pending log bio
231 * @biop: Address of the bio pointer
234 * Submit any pending part-built or full bio to the block device. If
235 * there is no pending bio, then this is a no-op.
238 void gfs2_log_submit_bio(struct bio **biop, int opf)
240 struct bio *bio = *biop;
241 if (bio) {
242 struct gfs2_sbd *sdp = bio->bi_private;
244 bio->bi_opf = opf;
245 submit_bio(bio);
251 * gfs2_log_alloc_bio - Allocate a bio
256 * Allocate a new bio, initialize it with the given parameters and return it.
258 * Returns: The newly allocated bio
261 static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno,
265 struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
267 bio->bi_iter.bi_sector = blkno << sdp->sd_fsb2bb_shift;
268 bio_set_dev(bio, sb->s_bdev);
269 bio->bi_end_io = end_io;
270 bio->bi_private = sdp;
272 return bio;
276 * gfs2_log_get_bio - Get cached log bio, or allocate a new one
279 * @bio: The bio to get or allocate
282 * @flush: Always flush the current bio and allocate a new one?
284 * If there is a cached bio, then if the next block number is sequential
285 * with the previous one, return it, otherwise flush the bio to the
286 * device. If there is no cached bio, or we just flushed it, then
289 * Returns: The bio to use for log writes
292 static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno,
293 struct bio **biop, int op,
296 struct bio *bio = *biop;
298 if (bio) {
301 nblk = bio_end_sector(bio);
304 return bio;
320 * Try and add the page segment to the current bio. If that fails,
321 * submit the current bio to the device and create a new one, and
328 struct bio *bio;
331 bio = gfs2_log_get_bio(sdp, blkno, &sdp->sd_log_bio, REQ_OP_WRITE,
333 ret = bio_add_page(bio, page, size, offset);
335 bio = gfs2_log_get_bio(sdp, blkno, &sdp->sd_log_bio,
337 ret = bio_add_page(bio, page, size, offset);
384 * @bio: The bio
386 * Simply unlock the pages in the bio. The main thread will wait on them and
390 static void gfs2_end_log_read(struct bio *bio)
396 bio_for_each_segment_all(bvec, bio, iter_all) {
398 if (bio->bi_status) {
399 int err = blk_status_to_errno(bio->bi_status);
407 bio_put(bio);
452 * to obtain the page to add it to the bio and second when we do a
456 * used. Maybe we added it to a bio, but not submitted it for I/O. Or we
480 static struct bio *gfs2_chain_bio(struct bio *prev, unsigned int nr_iovecs)
482 struct bio *new;
516 struct bio *bio = NULL;
541 if (bio && (off || block < blocks_submitted + max_blocks)) {
544 if (bio_end_sector(bio) == sector) {
545 sz = bio_add_page(bio, page, bsize, off);
553 bio = gfs2_chain_bio(bio, blocks);
558 if (bio) {
560 submit_bio(bio);
563 bio = gfs2_log_alloc_bio(sdp, dblock, gfs2_end_log_read);
564 bio->bi_opf = REQ_OP_READ;
566 sz = bio_add_page(bio, page, bsize, off);
573 /* Keep at least one bio in flight */
585 if (bio)
586 submit_bio(bio);