mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Linux 3.14 compat: IO acct, global_page_state, etc
generic_start_io_acct/generic_end_io_acct in the master branch of the linux kernel requires that the request_queue be provided. Move the logic from freemem in the spl to arc_free_memory in arc.c. Do this so we can take advantage of global_page_state interface checks in zfs. Upstream kernel replaced struct block_device with struct gendisk in struct bio. Determine if the function bio_set_dev exists during configure and have zfs use that if it exists. bio_set_dev https://github.com/torvalds/linux/commit/74d4699 global_node_page_state https://github.com/torvalds/linux/commit/75ef718 io acct https://github.com/torvalds/linux/commit/d62e26b Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov> Closes #6635
This commit is contained in:
committed by
Brian Behlendorf
parent
90cdf2833d
commit
787acae0b5
+20
-2
@@ -4665,6 +4665,24 @@ arc_all_memory(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _KERNEL
|
||||
static uint64_t
|
||||
arc_free_memory(void)
|
||||
{
|
||||
#ifdef ZFS_GLOBAL_NODE_PAGE_STATE
|
||||
return (nr_free_pages() +
|
||||
global_node_page_state(NR_INACTIVE_FILE) +
|
||||
global_node_page_state(NR_INACTIVE_ANON) +
|
||||
global_node_page_state(NR_SLAB_RECLAIMABLE));
|
||||
#else
|
||||
return (nr_free_pages() +
|
||||
global_page_state(NR_INACTIVE_FILE) +
|
||||
global_page_state(NR_INACTIVE_ANON) +
|
||||
global_page_state(NR_SLAB_RECLAIMABLE));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef enum free_memory_reason_t {
|
||||
FMR_UNKNOWN,
|
||||
FMR_NEEDFREE,
|
||||
@@ -4701,7 +4719,7 @@ arc_available_memory(void)
|
||||
int64_t lowest = INT64_MAX;
|
||||
free_memory_reason_t r = FMR_UNKNOWN;
|
||||
#ifdef _KERNEL
|
||||
uint64_t available_memory = ptob(freemem);
|
||||
uint64_t available_memory = ptob(arc_free_memory());
|
||||
int64_t n;
|
||||
#ifdef __linux__
|
||||
pgcnt_t needfree = btop(arc_need_free);
|
||||
@@ -6904,7 +6922,7 @@ static int
|
||||
arc_memory_throttle(uint64_t reserve, uint64_t txg)
|
||||
{
|
||||
#ifdef _KERNEL
|
||||
uint64_t available_memory = ptob(freemem);
|
||||
uint64_t available_memory = ptob(arc_free_memory());
|
||||
static uint64_t page_load = 0;
|
||||
static uint64_t last_txg = 0;
|
||||
#ifdef __linux__
|
||||
|
||||
+10
-2
@@ -503,6 +503,14 @@ vdev_submit_bio_impl(struct bio *bio)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef HAVE_BIO_SET_DEV
|
||||
static inline void
|
||||
bio_set_dev(struct bio *bio, struct block_device *bdev)
|
||||
{
|
||||
bio->bi_bdev = bdev;
|
||||
}
|
||||
#endif /* !HAVE_BIO_SET_DEV */
|
||||
|
||||
static inline void
|
||||
vdev_submit_bio(struct bio *bio)
|
||||
{
|
||||
@@ -585,7 +593,7 @@ retry:
|
||||
/* Matching put called by vdev_disk_physio_completion */
|
||||
vdev_disk_dio_get(dr);
|
||||
|
||||
dr->dr_bio[i]->bi_bdev = bdev;
|
||||
bio_set_dev(dr->dr_bio[i], bdev);
|
||||
BIO_BI_SECTOR(dr->dr_bio[i]) = bio_offset >> 9;
|
||||
dr->dr_bio[i]->bi_end_io = vdev_disk_physio_completion;
|
||||
dr->dr_bio[i]->bi_private = dr;
|
||||
@@ -659,7 +667,7 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
|
||||
|
||||
bio->bi_end_io = vdev_disk_io_flush_completion;
|
||||
bio->bi_private = zio;
|
||||
bio->bi_bdev = bdev;
|
||||
bio_set_dev(bio, bdev);
|
||||
bio_set_flush(bio);
|
||||
vdev_submit_bio(bio);
|
||||
invalidate_bdev(bdev);
|
||||
|
||||
+12
-6
@@ -761,7 +761,8 @@ zvol_write(void *arg)
|
||||
ASSERT(zv && zv->zv_open_count > 0);
|
||||
|
||||
start_jif = jiffies;
|
||||
generic_start_io_acct(WRITE, bio_sectors(bio), &zv->zv_disk->part0);
|
||||
blk_generic_start_io_acct(zv->zv_queue, WRITE, bio_sectors(bio),
|
||||
&zv->zv_disk->part0);
|
||||
|
||||
sync = bio_is_fua(bio) || zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS;
|
||||
|
||||
@@ -794,7 +795,8 @@ zvol_write(void *arg)
|
||||
zil_commit(zv->zv_zilog, ZVOL_OBJ);
|
||||
|
||||
rw_exit(&zv->zv_suspend_lock);
|
||||
generic_end_io_acct(WRITE, &zv->zv_disk->part0, start_jif);
|
||||
blk_generic_end_io_acct(zv->zv_queue, WRITE, &zv->zv_disk->part0,
|
||||
start_jif);
|
||||
BIO_END_IO(bio, -error);
|
||||
kmem_free(zvr, sizeof (zv_request_t));
|
||||
}
|
||||
@@ -840,7 +842,8 @@ zvol_discard(void *arg)
|
||||
ASSERT(zv && zv->zv_open_count > 0);
|
||||
|
||||
start_jif = jiffies;
|
||||
generic_start_io_acct(WRITE, bio_sectors(bio), &zv->zv_disk->part0);
|
||||
blk_generic_start_io_acct(zv->zv_queue, WRITE, bio_sectors(bio),
|
||||
&zv->zv_disk->part0);
|
||||
|
||||
sync = bio_is_fua(bio) || zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS;
|
||||
|
||||
@@ -881,7 +884,8 @@ unlock:
|
||||
zil_commit(zv->zv_zilog, ZVOL_OBJ);
|
||||
|
||||
rw_exit(&zv->zv_suspend_lock);
|
||||
generic_end_io_acct(WRITE, &zv->zv_disk->part0, start_jif);
|
||||
blk_generic_end_io_acct(zv->zv_queue, WRITE, &zv->zv_disk->part0,
|
||||
start_jif);
|
||||
BIO_END_IO(bio, -error);
|
||||
kmem_free(zvr, sizeof (zv_request_t));
|
||||
}
|
||||
@@ -902,7 +906,8 @@ zvol_read(void *arg)
|
||||
ASSERT(zv && zv->zv_open_count > 0);
|
||||
|
||||
start_jif = jiffies;
|
||||
generic_start_io_acct(READ, bio_sectors(bio), &zv->zv_disk->part0);
|
||||
blk_generic_start_io_acct(zv->zv_queue, READ, bio_sectors(bio),
|
||||
&zv->zv_disk->part0);
|
||||
|
||||
while (uio.uio_resid > 0 && uio.uio_loffset < volsize) {
|
||||
uint64_t bytes = MIN(uio.uio_resid, DMU_MAX_ACCESS >> 1);
|
||||
@@ -922,7 +927,8 @@ zvol_read(void *arg)
|
||||
zfs_range_unlock(zvr->rl);
|
||||
|
||||
rw_exit(&zv->zv_suspend_lock);
|
||||
generic_end_io_acct(READ, &zv->zv_disk->part0, start_jif);
|
||||
blk_generic_end_io_acct(zv->zv_queue, READ, &zv->zv_disk->part0,
|
||||
start_jif);
|
||||
BIO_END_IO(bio, -error);
|
||||
kmem_free(zvr, sizeof (zv_request_t));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user