Reintroduce IO accounting on zvols on Linux 3.19+
zfsonlinux/zfs@e20cd6f7a8 caused us to lose IO accounting on zvols. When I originally wrote that last year, the symbols we needed to maintain IO accounting were GPL exported, but torvalds/linux@394ffa503b provided suitable symbols for restoring this functionality 4 months later. We can call them to restore the IO accounting on Linux 3.19 and later as well as any older kernels where that patch is backported. Signed-off-by: Richard Yao <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3741
This commit is contained in:
parent
1e17e910ea
commit
8198d18ca7
|
@ -0,0 +1,26 @@
|
||||||
|
dnl #
|
||||||
|
dnl # 3.19 API addition
|
||||||
|
dnl #
|
||||||
|
dnl # torvalds/linux@394ffa503bc40e32d7f54a9b817264e81ce131b4 allows us to
|
||||||
|
dnl # increment iostat counters without generic_make_request().
|
||||||
|
dnl #
|
||||||
|
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [
|
||||||
|
AC_MSG_CHECKING([whether generic IO accounting symbols are avaliable])
|
||||||
|
ZFS_LINUX_TRY_COMPILE_SYMBOL([
|
||||||
|
#include <linux/bio.h>
|
||||||
|
|
||||||
|
void (*generic_start_io_acct_f)(int, unsigned long,
|
||||||
|
struct hd_struct *) = &generic_start_io_acct;
|
||||||
|
void (*generic_end_io_acct_f)(int, struct hd_struct *,
|
||||||
|
unsigned long) = &generic_end_io_acct;
|
||||||
|
], [
|
||||||
|
generic_start_io_acct(0, 0, NULL);
|
||||||
|
generic_end_io_acct(0, NULL, 0);
|
||||||
|
], [generic_start_io_acct], [block/bio.c], [
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_GENERIC_IO_ACCT, 1,
|
||||||
|
[generic_start_io_acct()/generic_end_io_acct() avaliable])
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
])
|
||||||
|
])
|
|
@ -94,6 +94,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
|
||||||
ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
|
ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
|
||||||
ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
|
ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
|
||||||
ZFS_AC_KERNEL_MAKE_REQUEST_FN
|
ZFS_AC_KERNEL_MAKE_REQUEST_FN
|
||||||
|
ZFS_AC_KERNEL_GENERIC_IO_ACCT
|
||||||
|
|
||||||
AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
|
AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
|
||||||
KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
|
KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
|
||||||
|
|
|
@ -343,4 +343,9 @@ blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
|
||||||
*/
|
*/
|
||||||
#define VDEV_HOLDER ((void *)0x2401de7)
|
#define VDEV_HOLDER ((void *)0x2401de7)
|
||||||
|
|
||||||
|
#ifndef HAVE_GENERIC_IO_ACCT
|
||||||
|
#define generic_start_io_acct(rw, slen, part) ((void)0)
|
||||||
|
#define generic_end_io_acct(rw, part, start_jiffies) ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _ZFS_BLKDEV_H */
|
#endif /* _ZFS_BLKDEV_H */
|
||||||
|
|
|
@ -713,6 +713,10 @@ zvol_request(struct request_queue *q, struct bio *bio)
|
||||||
fstrans_cookie_t cookie = spl_fstrans_mark();
|
fstrans_cookie_t cookie = spl_fstrans_mark();
|
||||||
uint64_t offset = BIO_BI_SECTOR(bio);
|
uint64_t offset = BIO_BI_SECTOR(bio);
|
||||||
unsigned int sectors = bio_sectors(bio);
|
unsigned int sectors = bio_sectors(bio);
|
||||||
|
int rw = bio_data_dir(bio);
|
||||||
|
#ifdef HAVE_GENERIC_IO_ACCT
|
||||||
|
unsigned long start = jiffies;
|
||||||
|
#endif
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
if (bio_has_data(bio) && offset + sectors >
|
if (bio_has_data(bio) && offset + sectors >
|
||||||
|
@ -723,25 +727,29 @@ zvol_request(struct request_queue *q, struct bio *bio)
|
||||||
(long long unsigned)offset,
|
(long long unsigned)offset,
|
||||||
(long unsigned)sectors);
|
(long unsigned)sectors);
|
||||||
error = SET_ERROR(EIO);
|
error = SET_ERROR(EIO);
|
||||||
goto out;
|
goto out1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bio_data_dir(bio) == WRITE) {
|
generic_start_io_acct(rw, sectors, &zv->zv_disk->part0);
|
||||||
|
|
||||||
|
if (rw == WRITE) {
|
||||||
if (unlikely(zv->zv_flags & ZVOL_RDONLY)) {
|
if (unlikely(zv->zv_flags & ZVOL_RDONLY)) {
|
||||||
error = SET_ERROR(EROFS);
|
error = SET_ERROR(EROFS);
|
||||||
goto out;
|
goto out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bio->bi_rw & VDEV_REQ_DISCARD) {
|
if (bio->bi_rw & VDEV_REQ_DISCARD) {
|
||||||
error = zvol_discard(bio);
|
error = zvol_discard(bio);
|
||||||
goto out;
|
goto out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = zvol_write(bio);
|
error = zvol_write(bio);
|
||||||
} else
|
} else
|
||||||
error = zvol_read(bio);
|
error = zvol_read(bio);
|
||||||
|
|
||||||
out:
|
out2:
|
||||||
|
generic_end_io_acct(rw, &zv->zv_disk->part0, start);
|
||||||
|
out1:
|
||||||
bio_endio(bio, -error);
|
bio_endio(bio, -error);
|
||||||
spl_fstrans_unmark(cookie);
|
spl_fstrans_unmark(cookie);
|
||||||
#ifdef HAVE_MAKE_REQUEST_FN_RET_INT
|
#ifdef HAVE_MAKE_REQUEST_FN_RET_INT
|
||||||
|
|
Loading…
Reference in New Issue