···17691769 where = ELEVATOR_INSERT_FLUSH;1770177017711771 add_acct_request(q, rq, where);17721772+ if (where == ELEVATOR_INSERT_FLUSH)17731773+ __blk_run_queue(q);17721774 spin_unlock_irqrestore(q->queue_lock, flags);1773177517741776 return 0;
+1-2
block/blk-flush.c
···320320 return;321321 }322322323323- BUG_ON(!rq->bio || rq->bio != rq->biotail);323323+ BUG_ON(rq->bio != rq->biotail); /*assumes zero or single bio rq */324324325325 /*326326 * If there's data but flush is not necessary, the request can be···330330 if ((policy & REQ_FSEQ_DATA) &&331331 !(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {332332 list_add_tail(&rq->queuelist, &q->queue_head);333333- blk_run_queue_async(q);334333 return;335334 }336335
+26-115
drivers/block/loop.c
···203203}204204205205/**206206- * do_lo_send_aops - helper for writing data to a loop device207207- *208208- * This is the fast version for backing filesystems which implement the address209209- * space operations write_begin and write_end.210210- */211211-static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,212212- loff_t pos, struct page *unused)213213-{214214- struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */215215- struct address_space *mapping = file->f_mapping;216216- pgoff_t index;217217- unsigned offset, bv_offs;218218- int len, ret;219219-220220- mutex_lock(&mapping->host->i_mutex);221221- index = pos >> PAGE_CACHE_SHIFT;222222- offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1);223223- bv_offs = bvec->bv_offset;224224- len = bvec->bv_len;225225- while (len > 0) {226226- sector_t IV;227227- unsigned size, copied;228228- int transfer_result;229229- struct page *page;230230- void *fsdata;231231-232232- IV = ((sector_t)index << (PAGE_CACHE_SHIFT - 9))+(offset >> 9);233233- size = PAGE_CACHE_SIZE - offset;234234- if (size > len)235235- size = len;236236-237237- ret = pagecache_write_begin(file, mapping, pos, size, 0,238238- &page, &fsdata);239239- if (ret)240240- goto fail;241241-242242- file_update_time(file);243243-244244- transfer_result = lo_do_transfer(lo, WRITE, page, offset,245245- bvec->bv_page, bv_offs, size, IV);246246- copied = size;247247- if (unlikely(transfer_result))248248- copied = 0;249249-250250- ret = pagecache_write_end(file, mapping, pos, size, copied,251251- page, fsdata);252252- if (ret < 0 || ret != copied)253253- goto fail;254254-255255- if (unlikely(transfer_result))256256- goto fail;257257-258258- bv_offs += copied;259259- len -= copied;260260- offset = 0;261261- index++;262262- pos += copied;263263- }264264- ret = 0;265265-out:266266- mutex_unlock(&mapping->host->i_mutex);267267- return ret;268268-fail:269269- ret = -1;270270- goto out;271271-}272272-273273-/**274206 * __do_lo_send_write - helper for writing data to a loop device275207 *276208 * This helper just factors out common code between do_lo_send_direct_write()···229297/**230298 * do_lo_send_direct_write - helper for writing data to a loop device231299 *232232- * This is the fast, non-transforming version for backing filesystems which do233233- * not implement the address space operations write_begin and write_end.234234- * It uses the write file operation which should be present on all writeable235235- * filesystems.300300+ * This is the fast, non-transforming version that does not need double301301+ * buffering.236302 */237303static int do_lo_send_direct_write(struct loop_device *lo,238304 struct bio_vec *bvec, loff_t pos, struct page *page)···246316/**247317 * do_lo_send_write - helper for writing data to a loop device248318 *249249- * This is the slow, transforming version for filesystems which do not250250- * implement the address space operations write_begin and write_end. It251251- * uses the write file operation which should be present on all writeable252252- * filesystems.253253- *254254- * Using fops->write is slower than using aops->{prepare,commit}_write in the255255- * transforming case because we need to double buffer the data as we cannot do256256- * the transformations in place as we do not have direct access to the257257- * destination pages of the backing file.319319+ * This is the slow, transforming version that needs to double buffer the320320+ * data as it cannot do the transformations in place without having direct321321+ * access to the destination pages of the backing file.258322 */259323static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec,260324 loff_t pos, struct page *page)···274350 struct page *page = NULL;275351 int i, ret = 0;276352277277- do_lo_send = do_lo_send_aops;278278- if (!(lo->lo_flags & LO_FLAGS_USE_AOPS)) {353353+ if (lo->transfer != transfer_none) {354354+ page = alloc_page(GFP_NOIO | __GFP_HIGHMEM);355355+ if (unlikely(!page))356356+ goto fail;357357+ kmap(page);358358+ do_lo_send = do_lo_send_write;359359+ } else {279360 do_lo_send = do_lo_send_direct_write;280280- if (lo->transfer != transfer_none) {281281- page = alloc_page(GFP_NOIO | __GFP_HIGHMEM);282282- if (unlikely(!page))283283- goto fail;284284- kmap(page);285285- do_lo_send = do_lo_send_write;286286- }287361 }362362+288363 bio_for_each_segment(bvec, bio, i) {289364 ret = do_lo_send(lo, bvec, pos, page);290365 if (ret < 0)···771848 mapping = file->f_mapping;772849 inode = mapping->host;773850774774- if (!(file->f_mode & FMODE_WRITE))775775- lo_flags |= LO_FLAGS_READ_ONLY;776776-777851 error = -EINVAL;778778- if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) {779779- const struct address_space_operations *aops = mapping->a_ops;780780-781781- if (aops->write_begin)782782- lo_flags |= LO_FLAGS_USE_AOPS;783783- if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write)784784- lo_flags |= LO_FLAGS_READ_ONLY;785785-786786- lo_blocksize = S_ISBLK(inode->i_mode) ?787787- inode->i_bdev->bd_block_size : PAGE_SIZE;788788-789789- error = 0;790790- } else {852852+ if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))791853 goto out_putf;792792- }793854794794- size = get_loop_size(lo, file);795795-796796- if ((loff_t)(sector_t)size != size) {797797- error = -EFBIG;798798- goto out_putf;799799- }800800-801801- if (!(mode & FMODE_WRITE))855855+ if (!(file->f_mode & FMODE_WRITE) || !(mode & FMODE_WRITE) ||856856+ !file->f_op->write)802857 lo_flags |= LO_FLAGS_READ_ONLY;858858+859859+ lo_blocksize = S_ISBLK(inode->i_mode) ?860860+ inode->i_bdev->bd_block_size : PAGE_SIZE;861861+862862+ error = -EFBIG;863863+ size = get_loop_size(lo, file);864864+ if ((loff_t)(sector_t)size != size)865865+ goto out_putf;866866+867867+ error = 0;803868804869 set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0);805870