mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-26 04:07:45 +03:00
Remove dummy znode from zvol_state
struct zvol_state contains a dummy znode, which is around 1KB on x64, only for zfs_range_lock. But in reality, other than z_range_lock and z_range_avl, zfs_range_lock only need znode on regular file, which means we add 1KB on a structure and gain nothing. In this patch, we remove the dummy znode for zvol_state. In order to do that, we also need to refactor zfs_range_lock a bit. We move z_range_lock and z_range_avl pair out of znode_t to form zfs_rlock_t. This new struct replaces znode_t as the main handle inside the range lock functions. We also add pointers to z_size, z_blksz, and z_max_blksz so range lock code doesn't depend on znode_t. This allows non-ZPL consumers like Lustre to use the range locks with their equivalent znode_t structure. Signed-off-by: Chunwei Chen <david.chen@osnexus.com> Signed-off-by: Boris Protopopov <boris.protopopov@actifio.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4510
This commit is contained in:
committed by
Brian Behlendorf
parent
61a3d06f84
commit
d88895a069
@@ -483,7 +483,8 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
|
||||
/*
|
||||
* Lock the range against changes.
|
||||
*/
|
||||
rl = zfs_range_lock(zp, uio->uio_loffset, uio->uio_resid, RL_READER);
|
||||
rl = zfs_range_lock(&zp->z_range_lock, uio->uio_loffset, uio->uio_resid,
|
||||
RL_READER);
|
||||
|
||||
/*
|
||||
* If we are reading past end-of-file we can skip
|
||||
@@ -673,7 +674,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
|
||||
* Obtain an appending range lock to guarantee file append
|
||||
* semantics. We reset the write offset once we have the lock.
|
||||
*/
|
||||
rl = zfs_range_lock(zp, 0, n, RL_APPEND);
|
||||
rl = zfs_range_lock(&zp->z_range_lock, 0, n, RL_APPEND);
|
||||
woff = rl->r_off;
|
||||
if (rl->r_len == UINT64_MAX) {
|
||||
/*
|
||||
@@ -690,7 +691,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
|
||||
* this write, then this range lock will lock the entire file
|
||||
* so that we can re-write the block safely.
|
||||
*/
|
||||
rl = zfs_range_lock(zp, woff, n, RL_WRITER);
|
||||
rl = zfs_range_lock(&zp->z_range_lock, woff, n, RL_WRITER);
|
||||
}
|
||||
|
||||
if (woff >= limit) {
|
||||
@@ -1016,7 +1017,8 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
|
||||
* we don't have to write the data twice.
|
||||
*/
|
||||
if (buf != NULL) { /* immediate write */
|
||||
zgd->zgd_rl = zfs_range_lock(zp, offset, size, RL_READER);
|
||||
zgd->zgd_rl = zfs_range_lock(&zp->z_range_lock, offset, size,
|
||||
RL_READER);
|
||||
/* test for truncation needs to be done while range locked */
|
||||
if (offset >= zp->z_size) {
|
||||
error = SET_ERROR(ENOENT);
|
||||
@@ -1037,8 +1039,8 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
|
||||
size = zp->z_blksz;
|
||||
blkoff = ISP2(size) ? P2PHASE(offset, size) : offset;
|
||||
offset -= blkoff;
|
||||
zgd->zgd_rl = zfs_range_lock(zp, offset, size,
|
||||
RL_READER);
|
||||
zgd->zgd_rl = zfs_range_lock(&zp->z_range_lock, offset,
|
||||
size, RL_READER);
|
||||
if (zp->z_blksz == size)
|
||||
break;
|
||||
offset += blkoff;
|
||||
@@ -4007,7 +4009,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc)
|
||||
redirty_page_for_writepage(wbc, pp);
|
||||
unlock_page(pp);
|
||||
|
||||
rl = zfs_range_lock(zp, pgoff, pglen, RL_WRITER);
|
||||
rl = zfs_range_lock(&zp->z_range_lock, pgoff, pglen, RL_WRITER);
|
||||
lock_page(pp);
|
||||
|
||||
/* Page mapping changed or it was no longer dirty, we're done */
|
||||
|
||||
Reference in New Issue
Block a user