Skip to content

Commit b1f07ca

Browse files
pjdandrewc12
authored andcommitted
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Pawel Jakub Dawidek <[email protected]> Closes openzfs#13400
1 parent 34957a3 commit b1f07ca

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

include/os/freebsd/spl/sys/vnode.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,7 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync)
136136
#define va_blksize va_blocksize
137137

138138
#define MAXOFFSET_T OFF_MAX
139-
#define EXCL 0
140139

141-
#define FCREAT O_CREAT
142-
#define FTRUNC O_TRUNC
143-
#define FEXCL O_EXCL
144-
#ifndef FDSYNC
145-
#define FDSYNC FFSYNC
146-
#endif
147-
#define FRSYNC FFSYNC
148-
#define FSYNC FFSYNC
149-
#define FOFFMAX 0x00
150140
#define FIGNORECASE 0x00
151141

152142
/*

lib/libspl/include/os/freebsd/sys/file.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@
2929

3030
#include_next <sys/file.h>
3131

32-
#define FCREAT O_CREAT
33-
#define FTRUNC O_TRUNC
34-
#define FSYNC O_SYNC
35-
#define FDSYNC O_DSYNC
36-
#define FEXCL O_EXCL
37-
38-
#define FNODSYNC 0x10000 /* fsync pseudo flag */
39-
#define FNOFOLLOW 0x20000 /* don't follow symlinks */
4032
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
4133

4234
#endif

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ zfs_open(vnode_t **vpp, int flag, cred_t *cr)
241241
}
242242

243243
/* Keep a count of the synchronous opens in the znode */
244-
if (flag & (FSYNC | FDSYNC))
244+
if (flag & O_SYNC)
245245
atomic_inc_32(&zp->z_sync_cnt);
246246

247247
ZFS_EXIT(zfsvfs);
@@ -259,7 +259,7 @@ zfs_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr)
259259
ZFS_VERIFY_ZP(zp);
260260

261261
/* Decrement the synchronous opens in the znode */
262-
if ((flag & (FSYNC | FDSYNC)) && (count == 1))
262+
if ((flag & O_SYNC) && (count == 1))
263263
atomic_dec_32(&zp->z_sync_cnt);
264264

265265
ZFS_EXIT(zfsvfs);
@@ -4402,11 +4402,11 @@ ioflags(int ioflags)
44024402
int flags = 0;
44034403

44044404
if (ioflags & IO_APPEND)
4405-
flags |= FAPPEND;
4405+
flags |= O_APPEND;
44064406
if (ioflags & IO_NDELAY)
4407-
flags |= FNONBLOCK;
4407+
flags |= O_NONBLOCK;
44084408
if (ioflags & IO_SYNC)
4409-
flags |= (FSYNC | FDSYNC | FRSYNC);
4409+
flags |= O_SYNC;
44104410

44114411
return (flags);
44124412
}
@@ -4627,7 +4627,7 @@ zfs_freebsd_create(struct vop_create_args *ap)
46274627
zfsvfs = ap->a_dvp->v_mount->mnt_data;
46284628
*ap->a_vpp = NULL;
46294629

4630-
rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, !EXCL, mode,
4630+
rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, 0, mode,
46314631
&zp, cnp->cn_cred, 0 /* flag */, NULL /* vsecattr */);
46324632
if (rc == 0)
46334633
*ap->a_vpp = ZTOV(zp);

module/os/freebsd/zfs/zvol_os.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,13 @@ zvol_geom_open(struct g_provider *pp, int flag, int count)
311311
err = SET_ERROR(EBUSY);
312312
goto out_opened;
313313
}
314-
#ifdef FEXCL
315-
if (flag & FEXCL) {
314+
if (flag & O_EXCL) {
316315
if (zv->zv_open_count != 0) {
317316
err = SET_ERROR(EBUSY);
318317
goto out_opened;
319318
}
320319
zv->zv_flags |= ZVOL_EXCL;
321320
}
322-
#endif
323321

324322
zv->zv_open_count += count;
325323
out_opened:
@@ -952,18 +950,16 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
952950
err = SET_ERROR(EBUSY);
953951
goto out_opened;
954952
}
955-
#ifdef FEXCL
956-
if (flags & FEXCL) {
953+
if (flags & O_EXCL) {
957954
if (zv->zv_open_count != 0) {
958955
err = SET_ERROR(EBUSY);
959956
goto out_opened;
960957
}
961958
zv->zv_flags |= ZVOL_EXCL;
962959
}
963-
#endif
964960

965961
zv->zv_open_count++;
966-
if (flags & (FSYNC | FDSYNC)) {
962+
if (flags & O_SYNC) {
967963
zsd = &zv->zv_zso->zso_dev;
968964
zsd->zsd_sync_cnt++;
969965
if (zsd->zsd_sync_cnt == 1 &&
@@ -1037,7 +1033,7 @@ zvol_cdev_close(struct cdev *dev, int flags, int fmt, struct thread *td)
10371033
* You may get multiple opens, but only one close.
10381034
*/
10391035
zv->zv_open_count--;
1040-
if (flags & (FSYNC | FDSYNC)) {
1036+
if (flags & O_SYNC) {
10411037
zsd = &zv->zv_zso->zso_dev;
10421038
zsd->zsd_sync_cnt--;
10431039
}

0 commit comments

Comments
 (0)