Skip to content

Commit

Permalink
Remove checks for mandatory locks
Browse files Browse the repository at this point in the history
The Linux VFS handles mandatory locks generically so we shouldn't
need to check for conflicting locks in zfs_read(), zfs_write(), or
zfs_freesp().  Linux 3.18 removed the lock_may_read() and
lock_may_write() interfaces which we were relying on for this
purpose.  Rather than emulating those interfaces we remove the
redundant checks.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2804
  • Loading branch information
nedbass authored and behlendorf committed Oct 22, 2014
1 parent 88904bb commit bc151f7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
18 changes: 0 additions & 18 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,6 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
return (0);
}

/*
* Check for mandatory locks
*/
if (mandatory_lock(ip) &&
!lock_may_read(ip, uio->uio_loffset, uio->uio_resid)) {
ZFS_EXIT(zsb);
return (SET_ERROR(EAGAIN));
}

/*
* If we're in FRSYNC mode, sync out this znode before reading it.
*/
Expand Down Expand Up @@ -650,15 +641,6 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
return (SET_ERROR(EINVAL));
}

/*
* Check for mandatory locks before calling zfs_range_lock()
* in order to prevent a deadlock with locks set via fcntl().
*/
if (mandatory_lock(ip) && !lock_may_write(ip, woff, n)) {
ZFS_EXIT(zsb);
return (SET_ERROR(EAGAIN));
}

/*
* Pre-fault the pages to ensure slow (eg NFS) pages
* don't hold up txg.
Expand Down
10 changes: 0 additions & 10 deletions module/zfs/zfs_znode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,6 @@ zfs_trunc(znode_t *zp, uint64_t end)
int
zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
{
struct inode *ip = ZTOI(zp);
dmu_tx_t *tx;
zfs_sb_t *zsb = ZTOZSB(zp);
zilog_t *zilog = zsb->z_log;
Expand All @@ -1567,15 +1566,6 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
goto out;
}

/*
* Check for any locks in the region to be freed.
*/
if (ip->i_flock && mandatory_lock(ip)) {
uint64_t length = (len ? len : zp->z_size - off);
if (!lock_may_write(ip, off, length))
return (SET_ERROR(EAGAIN));
}

if (len == 0) {
error = zfs_trunc(zp, off);
} else {
Expand Down

0 comments on commit bc151f7

Please sign in to comment.