[Devel] [PATCH 02/10] ploop: Make submit_alloc() return int value
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Mar 26 18:18:47 MSK 2019
-1 is error;
0 means this service preq is skipped;
1 is block was allocated
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/io_direct.c | 6 ++++--
drivers/block/ploop/io_kaio.c | 11 ++++++-----
include/linux/ploop/ploop.h | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 21cfdeb7441b..b1955d339de5 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -730,7 +730,7 @@ dio_submit_pad(struct ploop_io *io, struct ploop_request * preq,
PLOOP_FAIL_REQUEST(preq, err);
}
-static void
+static int
dio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
struct bio_list * sbl, unsigned int size)
{
@@ -741,7 +741,7 @@ dio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
if (!(io->files.file->f_mode & FMODE_WRITE)) {
PLOOP_FAIL_REQUEST(preq, -EBADF);
- return;
+ return -1;
}
err = cached_submit(io, iblk, preq, sbl, size, true);
@@ -749,8 +749,10 @@ dio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
if (err == -ENOSPC)
io->alloc_head--;
PLOOP_FAIL_REQUEST(preq, err);
+ return -1;
}
preq->eng_state = PLOOP_E_DATA_WBI;
+ return 1;
}
/* When backing fs does not export any method to allocate new blocks
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 84da1cec5643..1e4ae6efbe70 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -546,7 +546,7 @@ static int kaio_fsync_thread(void * data)
return 0;
}
-static void
+static int
kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
struct bio_list * sbl, unsigned int size)
{
@@ -558,7 +558,7 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
if (delta->flags & PLOOP_FMT_RDONLY) {
PLOOP_FAIL_REQUEST(preq, -EBADF);
- return;
+ return -1;
}
iblk = io->alloc_head;
@@ -568,7 +568,7 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
kaio_queue_fsync_req(preq);
io->plo->st.bio_syncwait++;
spin_unlock_irq(&io->plo->lock);
- return;
+ return 0;
}
BUG_ON(preq->prealloc_size);
@@ -586,11 +586,11 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
kaio_queue_trunc_req(preq);
io->plo->st.bio_syncwait++;
spin_unlock_irq(&io->plo->lock);
- return;
+ return 0;
} else { /* we're not first */
list_add_tail(&preq->list,
&io->prealloc_preq->delay_list);
- return;
+ return 0;
}
}
@@ -600,6 +600,7 @@ kaio_submit_alloc(struct ploop_io *io, struct ploop_request * preq,
preq->eng_state = PLOOP_E_DATA_WBI;
kaio_sbl_submit(io->files.file, preq, REQ_WRITE, sbl, iblk, size);
+ return 1;
}
static int kaio_release_prealloced(struct ploop_io * io)
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index b209c9f096a8..599f7dbff7f2 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -159,7 +159,7 @@ struct ploop_io_ops
void (*submit)(struct ploop_io *, struct ploop_request *,
unsigned long rw,
struct bio_list *sbl, iblock_t iblk, unsigned int size);
- void (*submit_alloc)(struct ploop_io *, struct ploop_request *,
+ int (*submit_alloc)(struct ploop_io *, struct ploop_request *,
struct bio_list *sbl, unsigned int size);
void (*post_submit)(struct ploop_io *, struct ploop_request *);
More information about the Devel
mailing list