On Mon, 13 Jan 2014, Mike Snitzer wrote: > On Sat, Jan 11 2014 at 12:29pm -0500, > Mikulas Patocka <mpatocka@xxxxxxxxxx> wrote: > > > This patch makes dm_bufio_prefetch return 1 on success and 0 on failure. > > A prefetch failure may happen in case of temporary memory shortage. > > > > Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx> > > > > --- > > drivers/md/dm-bufio.c | 8 ++++++-- > > drivers/md/dm-bufio.h | 4 ++-- > > 2 files changed, 8 insertions(+), 4 deletions(-) > > > > Index: linux-3.13-rc7/drivers/md/dm-bufio.c > > =================================================================== > > --- linux-3.13-rc7.orig/drivers/md/dm-bufio.c 2014-01-09 16:11:31.000000000 +0100 > > +++ linux-3.13-rc7/drivers/md/dm-bufio.c 2014-01-09 16:16:43.000000000 +0100 > > @@ -1068,10 +1068,11 @@ void *dm_bufio_new(struct dm_bufio_clien > > } > > EXPORT_SYMBOL_GPL(dm_bufio_new); > > > > -void dm_bufio_prefetch(struct dm_bufio_client *c, > > +int dm_bufio_prefetch(struct dm_bufio_client *c, > > sector_t block, unsigned n_blocks) > > { > > struct blk_plug plug; > > + int success = 1; > > > > LIST_HEAD(write_list); > > > > I'd prefer to see a bool used here. Or an actual error code like > -ENOMEM. > > > @@ -1104,13 +1105,16 @@ void dm_bufio_prefetch(struct dm_bufio_c > > if (!n_blocks) > > goto flush_plug; > > dm_bufio_lock(c); > > - } > > + } else > > + success = 0; > > Why do you continue to do work if a prefetch failed? Why not return > early here? I realized that the patch for the return values was wrong (it would return 0 if some buffers were already prefetched). And it's not really needed, if dm_bufio_prefetch doesn't do prefetch because of memory shortage, we can do nothing as dm_bufio_read will read that buffer anyway. So, I am sending next 6-patch series, it's the same without the first patch. Mikulas -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel