mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
FreeBSD: Clean up the use of ioflags
- Prefer O_* flags over F* flags that mostly mirror O_* flags anyway, but O_* flags seem to be preferred. - Simplify the code as all the F*SYNC flags were defined as FFSYNC flag. - Don't define FRSYNC flag, so we don't generate unnecessary ZIL commits. - Remove EXCL define, FreeBSD ignores the excl argument for zfs_create() anyway. Reviewed-by: Allan Jude <allan@klarasystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net> Closes #13400
This commit is contained in:
parent
159c6fd154
commit
a64d757aa4
@ -136,17 +136,7 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync)
|
|||||||
#define va_blksize va_blocksize
|
#define va_blksize va_blocksize
|
||||||
|
|
||||||
#define MAXOFFSET_T OFF_MAX
|
#define MAXOFFSET_T OFF_MAX
|
||||||
#define EXCL 0
|
|
||||||
|
|
||||||
#define FCREAT O_CREAT
|
|
||||||
#define FTRUNC O_TRUNC
|
|
||||||
#define FEXCL O_EXCL
|
|
||||||
#ifndef FDSYNC
|
|
||||||
#define FDSYNC FFSYNC
|
|
||||||
#endif
|
|
||||||
#define FRSYNC FFSYNC
|
|
||||||
#define FSYNC FFSYNC
|
|
||||||
#define FOFFMAX 0x00
|
|
||||||
#define FIGNORECASE 0x00
|
#define FIGNORECASE 0x00
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -29,14 +29,6 @@
|
|||||||
|
|
||||||
#include_next <sys/file.h>
|
#include_next <sys/file.h>
|
||||||
|
|
||||||
#define FCREAT O_CREAT
|
|
||||||
#define FTRUNC O_TRUNC
|
|
||||||
#define FSYNC O_SYNC
|
|
||||||
#define FDSYNC O_DSYNC
|
|
||||||
#define FEXCL O_EXCL
|
|
||||||
|
|
||||||
#define FNODSYNC 0x10000 /* fsync pseudo flag */
|
|
||||||
#define FNOFOLLOW 0x20000 /* don't follow symlinks */
|
|
||||||
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
|
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -241,7 +241,7 @@ zfs_open(vnode_t **vpp, int flag, cred_t *cr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Keep a count of the synchronous opens in the znode */
|
/* Keep a count of the synchronous opens in the znode */
|
||||||
if (flag & (FSYNC | FDSYNC))
|
if (flag & O_SYNC)
|
||||||
atomic_inc_32(&zp->z_sync_cnt);
|
atomic_inc_32(&zp->z_sync_cnt);
|
||||||
|
|
||||||
ZFS_EXIT(zfsvfs);
|
ZFS_EXIT(zfsvfs);
|
||||||
@ -259,7 +259,7 @@ zfs_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr)
|
|||||||
ZFS_VERIFY_ZP(zp);
|
ZFS_VERIFY_ZP(zp);
|
||||||
|
|
||||||
/* Decrement the synchronous opens in the znode */
|
/* Decrement the synchronous opens in the znode */
|
||||||
if ((flag & (FSYNC | FDSYNC)) && (count == 1))
|
if ((flag & O_SYNC) && (count == 1))
|
||||||
atomic_dec_32(&zp->z_sync_cnt);
|
atomic_dec_32(&zp->z_sync_cnt);
|
||||||
|
|
||||||
ZFS_EXIT(zfsvfs);
|
ZFS_EXIT(zfsvfs);
|
||||||
@ -4402,11 +4402,11 @@ ioflags(int ioflags)
|
|||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (ioflags & IO_APPEND)
|
if (ioflags & IO_APPEND)
|
||||||
flags |= FAPPEND;
|
flags |= O_APPEND;
|
||||||
if (ioflags & IO_NDELAY)
|
if (ioflags & IO_NDELAY)
|
||||||
flags |= FNONBLOCK;
|
flags |= O_NONBLOCK;
|
||||||
if (ioflags & IO_SYNC)
|
if (ioflags & IO_SYNC)
|
||||||
flags |= (FSYNC | FDSYNC | FRSYNC);
|
flags |= O_SYNC;
|
||||||
|
|
||||||
return (flags);
|
return (flags);
|
||||||
}
|
}
|
||||||
@ -4627,7 +4627,7 @@ zfs_freebsd_create(struct vop_create_args *ap)
|
|||||||
zfsvfs = ap->a_dvp->v_mount->mnt_data;
|
zfsvfs = ap->a_dvp->v_mount->mnt_data;
|
||||||
*ap->a_vpp = NULL;
|
*ap->a_vpp = NULL;
|
||||||
|
|
||||||
rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, !EXCL, mode,
|
rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, 0, mode,
|
||||||
&zp, cnp->cn_cred, 0 /* flag */, NULL /* vsecattr */);
|
&zp, cnp->cn_cred, 0 /* flag */, NULL /* vsecattr */);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
*ap->a_vpp = ZTOV(zp);
|
*ap->a_vpp = ZTOV(zp);
|
||||||
|
@ -311,15 +311,13 @@ retry:
|
|||||||
err = SET_ERROR(EBUSY);
|
err = SET_ERROR(EBUSY);
|
||||||
goto out_opened;
|
goto out_opened;
|
||||||
}
|
}
|
||||||
#ifdef FEXCL
|
if (flag & O_EXCL) {
|
||||||
if (flag & FEXCL) {
|
|
||||||
if (zv->zv_open_count != 0) {
|
if (zv->zv_open_count != 0) {
|
||||||
err = SET_ERROR(EBUSY);
|
err = SET_ERROR(EBUSY);
|
||||||
goto out_opened;
|
goto out_opened;
|
||||||
}
|
}
|
||||||
zv->zv_flags |= ZVOL_EXCL;
|
zv->zv_flags |= ZVOL_EXCL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
zv->zv_open_count += count;
|
zv->zv_open_count += count;
|
||||||
out_opened:
|
out_opened:
|
||||||
@ -952,18 +950,16 @@ retry:
|
|||||||
err = SET_ERROR(EBUSY);
|
err = SET_ERROR(EBUSY);
|
||||||
goto out_opened;
|
goto out_opened;
|
||||||
}
|
}
|
||||||
#ifdef FEXCL
|
if (flags & O_EXCL) {
|
||||||
if (flags & FEXCL) {
|
|
||||||
if (zv->zv_open_count != 0) {
|
if (zv->zv_open_count != 0) {
|
||||||
err = SET_ERROR(EBUSY);
|
err = SET_ERROR(EBUSY);
|
||||||
goto out_opened;
|
goto out_opened;
|
||||||
}
|
}
|
||||||
zv->zv_flags |= ZVOL_EXCL;
|
zv->zv_flags |= ZVOL_EXCL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
zv->zv_open_count++;
|
zv->zv_open_count++;
|
||||||
if (flags & (FSYNC | FDSYNC)) {
|
if (flags & O_SYNC) {
|
||||||
zsd = &zv->zv_zso->zso_dev;
|
zsd = &zv->zv_zso->zso_dev;
|
||||||
zsd->zsd_sync_cnt++;
|
zsd->zsd_sync_cnt++;
|
||||||
if (zsd->zsd_sync_cnt == 1 &&
|
if (zsd->zsd_sync_cnt == 1 &&
|
||||||
@ -1037,7 +1033,7 @@ zvol_cdev_close(struct cdev *dev, int flags, int fmt, struct thread *td)
|
|||||||
* You may get multiple opens, but only one close.
|
* You may get multiple opens, but only one close.
|
||||||
*/
|
*/
|
||||||
zv->zv_open_count--;
|
zv->zv_open_count--;
|
||||||
if (flags & (FSYNC | FDSYNC)) {
|
if (flags & O_SYNC) {
|
||||||
zsd = &zv->zv_zso->zso_dev;
|
zsd = &zv->zv_zso->zso_dev;
|
||||||
zsd->zsd_sync_cnt--;
|
zsd->zsd_sync_cnt--;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user