Make fs-specific fcntl macros take three arguments (approved wrstuden).

Let LFS use fcntl for cleaner functions.
This commit is contained in:
perseant 2003-02-25 23:12:06 +00:00
parent b06fa82f3e
commit 6f5626d112
6 changed files with 57 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cleanerd.c,v 1.44 2003/02/24 08:48:17 perseant Exp $ */
/* $NetBSD: cleanerd.c,v 1.45 2003/02/25 23:12:08 perseant Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -40,11 +40,11 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
#else
__RCSID("$NetBSD: cleanerd.c,v 1.44 2003/02/24 08:48:17 perseant Exp $");
__RCSID("$NetBSD: cleanerd.c,v 1.45 2003/02/25 23:12:08 perseant Exp $");
#endif
#endif /* not lint */
#include <sys/ioctl.h>
#include <sys/fcntl.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/time.h>
@ -125,40 +125,40 @@ void just_exit(int);
int main(int, char *[]);
/*
* Emulate lfs_{bmapv,markv,segwait} using ioctl calls.
* Emulate lfs_{bmapv,markv,segwait} using fcntl calls.
* NOTE: the old system calls still use BLOCK_INFO_15,
* while the ioctls use BLOCK_INFO.
* while the fcntls use BLOCK_INFO.
*/
int
lfs_markv_emul(int fd, BLOCK_INFO *blkiov, int blkcnt)
{
struct lfs_ioctl_markv /* {
struct lfs_fcntl_markv /* {
BLOCK_INFO *blkiov;
int blkcnt;
} */ lim;
lim.blkiov = blkiov;
lim.blkcnt = blkcnt;
return ioctl(fd, LIOCMARKV, &lim);
return fcntl(fd, LFCNMARKV, &lim);
}
int
lfs_bmapv_emul(int fd, BLOCK_INFO *blkiov, int blkcnt)
{
struct lfs_ioctl_markv /* {
struct lfs_fcntl_markv /* {
BLOCK_INFO *blkiov;
int blkcnt;
} */ lim;
lim.blkiov = blkiov;
lim.blkcnt = blkcnt;
return ioctl(fd, LIOCBMAPV, &lim);
return fcntl(fd, LFCNBMAPV, &lim);
}
int
lfs_segwait_emul(int fd, struct timeval *tv)
{
return ioctl(fd, LIOCSEGWAIT, tv);
return fcntl(fd, LFCNSEGWAIT, tv);
}
/*
@ -379,7 +379,7 @@ main(int argc, char **argv)
if(debug > 1)
syslog(LOG_DEBUG,"Cleaner going to sleep.");
if (lfs_segwait_emul(ifile_fd, &timeout) < 0)
syslog(LOG_WARNING,"LIOCSEGWAIT: %m");
syslog(LOG_WARNING,"LFCNSEGWAIT: %m");
if(debug > 1)
syslog(LOG_DEBUG,"Cleaner waking up.");
}
@ -728,7 +728,7 @@ add_segment(FS_INFO *fsp, struct seglist *slp, SEGS_AND_BLOCKS *sbp)
/* get the current disk address of blocks contained by the segment */
if ((error = lfs_bmapv_emul(ifile_fd, tba, num_blocks)) < 0) {
syslog(LOG_WARNING, "add_segment: LIOCBMAPV failed");
syslog(LOG_WARNING, "add_segment: LFCNBMAPV failed");
goto out;
}
@ -935,7 +935,7 @@ clean_segments(FS_INFO *fsp, SEGS_AND_BLOCKS *sbp)
for (bp = sbp->ba; sbp->nb > 0; bp += clean_blocks) {
clean_blocks = maxblocks < sbp->nb ? maxblocks : sbp->nb;
if ((error = lfs_markv_emul(ifile_fd, bp, clean_blocks)) < 0) {
syslog(LOG_WARNING,"clean_segment: LIOCMARKV failed: %m");
syslog(LOG_WARNING,"clean_segment: LFCNMARKV failed: %m");
++cleaner_stats.segs_error;
if (errno == ENOENT) break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: coalesce.c,v 1.7 2003/02/24 08:48:18 perseant Exp $ */
/* $NetBSD: coalesce.c,v 1.8 2003/02/25 23:12:08 perseant Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -106,7 +106,7 @@ char *coalesce_return[] = {
"Negative size",
"Not enough blocks to account for size",
"Malloc failed",
"LIOCBMAPV failed",
"LFCNBMAPV failed",
"Not broken enough to fix",
"Too many blocks not found",
"Too many blocks found in active segments",
@ -171,7 +171,7 @@ int clean_inode(struct fs_info *fsp, ino_t ino)
/* Don't set the size, but let lfs_bmap fill it in */
}
if ((error = lfs_bmapv_emul(ifile_fd, bip, nb)) < 0) {
syslog(LOG_WARNING, "LIOCBMAPV: %m");
syslog(LOG_WARNING, "LFCNBMAPV: %m");
retval = COALESCE_BADBMAPV;
goto out;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: fcntl.h,v 1.22 2002/12/06 22:43:35 christos Exp $ */
/* $NetBSD: fcntl.h,v 1.23 2003/02/25 23:12:06 perseant Exp $ */
/*-
* Copyright (c) 1983, 1990, 1993
@ -214,12 +214,13 @@
/*
* Define command macros for fs-specific commands.
*/
#define _FCN_FSPRIV(inout, num, len) \
(F_FSCTL | F_FSPRIV | inout | ((len & F_PARAM_MASK) << 16) | (num))
#define _FCNO_FSPRIV(c) _FCN_FSPRIV(F_FSVOID, (c), 0)
#define _FCNR_FSPRIV(c, t) _FCN_FSPRIV(F_FSIN, (c), (int)sizeof(t))
#define _FCNW_FSPRIV(c, t) _FCN_FSPRIV(F_FSOUT, (c), (int)sizeof(t))
#define _FCNRW_FSPRIV(c, t) _FCN_FSPRIV(F_FSINOUT, (c), (int)sizeof(t))
#define _FCN_FSPRIV(inout, fs, num, len) \
(F_FSCTL | F_FSPRIV | inout | ((len & F_PARAM_MASK) << 16) | \
(fs) << 8 | (num))
#define _FCNO_FSPRIV(f, c) _FCN_FSPRIV(F_FSVOID, (f), (c), 0)
#define _FCNR_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSIN, (f), (c), (int)sizeof(t))
#define _FCNW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSOUT, (f), (c), (int)sizeof(t))
#define _FCNRW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSINOUT, (f), (c), (int)sizeof(t))
#endif /* neither POSIX nor _XOPEN_SOURCE */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.h,v 1.51 2003/02/24 08:42:49 perseant Exp $ */
/* $NetBSD: lfs.h,v 1.52 2003/02/25 23:12:07 perseant Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -934,15 +934,15 @@ struct lfs_stats {
extern struct lfs_stats lfs_stats;
#endif
/* Ioctls to take the place of the lfs syscalls */
struct lfs_ioctl_markv {
/* Fcntls to take the place of the lfs syscalls */
struct lfs_fcntl_markv {
BLOCK_INFO *blkiov; /* blocks to relocate */
int blkcnt; /* number of blocks */
};
#define LIOCSEGWAITALL _IOW('L', 0, struct timeval)
#define LIOCSEGWAIT _IOW('L', 1, struct timeval)
#define LIOCBMAPV _IOWR('L', 2, struct lfs_ioctl_markv)
#define LIOCMARKV _IOWR('L', 3, struct lfs_ioctl_markv)
#define LFCNSEGWAITALL _FCNW_FSPRIV('L', 0, struct timeval)
#define LFCNSEGWAIT _FCNW_FSPRIV('L', 1, struct timeval)
#define LFCNBMAPV _FCNRW_FSPRIV('L', 2, struct lfs_fcntl_markv)
#define LFCNMARKV _FCNRW_FSPRIV('L', 3, struct lfs_fcntl_markv)
#endif /* !_UFS_LFS_LFS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_extern.h,v 1.43 2003/02/24 08:42:49 perseant Exp $ */
/* $NetBSD: lfs_extern.h,v 1.44 2003/02/25 23:12:07 perseant Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -245,7 +245,7 @@ int lfs_setattr (void *);
int lfs_close (void *);
int lfsspec_close(void *);
int lfsfifo_close(void *);
int lfs_ioctl (void *);
int lfs_fcntl (void *);
int lfs_inactive (void *);
int lfs_reclaim (void *);
int lfs_write (void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vnops.c,v 1.89 2003/02/24 08:42:49 perseant Exp $ */
/* $NetBSD: lfs_vnops.c,v 1.90 2003/02/25 23:12:07 perseant Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.89 2003/02/24 08:42:49 perseant Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.90 2003/02/25 23:12:07 perseant Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -126,8 +126,8 @@ const struct vnodeopv_entry_desc lfs_vnodeop_entries[] = {
{ &vop_read_desc, lfs_read }, /* read */
{ &vop_write_desc, lfs_write }, /* write */
{ &vop_lease_desc, ufs_lease_check }, /* lease */
{ &vop_ioctl_desc, lfs_ioctl }, /* ioctl */
{ &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
{ &vop_ioctl_desc, ufs_ioctl }, /* ioctl */
{ &vop_fcntl_desc, lfs_fcntl }, /* fcntl */
{ &vop_poll_desc, ufs_poll }, /* poll */
{ &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
{ &vop_revoke_desc, ufs_revoke }, /* revoke */
@ -1012,12 +1012,12 @@ lfs_reclaim(void *v)
}
/*
* Provide an ioctl interface to sys_lfs_{segwait,bmapv,markv}.
* Provide a fcntl interface to sys_lfs_{segwait,bmapv,markv}.
*/
int
lfs_ioctl(void *v)
lfs_fcntl(void *v)
{
struct vop_ioctl_args /* {
struct vop_fcntl_args /* {
struct vnode *a_vp;
u_long a_command;
caddr_t a_data;
@ -1028,34 +1028,33 @@ lfs_ioctl(void *v)
struct timeval *tvp;
BLOCK_INFO *blkiov;
int blkcnt, error;
struct lfs_ioctl_markv blkvp;
struct lfs_fcntl_markv blkvp;
fsid_t *fsidp;
/* Only respect LFS ioctls on fs root or Ifile */
/* Only respect LFS fcntls on fs root or Ifile */
if (VTOI(ap->a_vp)->i_number != ROOTINO &&
VTOI(ap->a_vp)->i_number != LFS_IFILE_INUM) {
return ufs_ioctl(v);
return ufs_fcntl(v);
}
fsidp = &ap->a_vp->v_mount->mnt_stat.f_fsid;
switch(ap->a_command) {
case LIOCSEGWAITALL:
case LFCNSEGWAITALL:
fsidp = NULL;
/* FALLSTHROUGH */
case LIOCSEGWAIT:
case LFCNSEGWAIT:
tvp = (struct timeval *)ap->a_data;
if ((error = lfs_segwait(fsidp, tvp)) != 0) {
VOP_UNLOCK(ap->a_vp, 0);
error = lfs_segwait(fsidp, tvp);
VOP_LOCK(ap->a_vp, LK_EXCLUSIVE);
return error;
}
/* copyout(&tv, ap->a_data, sizeof(tv)); */
return 0;
case LIOCBMAPV:
case LIOCMARKV:
case LFCNBMAPV:
case LFCNMARKV:
if ((error = suser(ap->a_p->p_ucred, &ap->a_p->p_acflag)) != 0)
return (error);
blkvp = *(struct lfs_ioctl_markv *)ap->a_data;
blkvp = *(struct lfs_fcntl_markv *)ap->a_data;
blkcnt = blkvp.blkcnt;
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
@ -1067,18 +1066,20 @@ lfs_ioctl(void *v)
return error;
}
if (ap->a_command == LIOCBMAPV)
VOP_UNLOCK(ap->a_vp, 0);
if (ap->a_command == LFCNBMAPV)
error = lfs_bmapv(ap->a_p, fsidp, blkiov, blkcnt);
else /* LIOCMARKV */
else /* LFCNMARKV */
error = lfs_markv(ap->a_p, fsidp, blkiov, blkcnt);
if (error == 0)
error = copyout(blkiov, blkvp.blkiov,
blkcnt * sizeof(BLOCK_INFO));
VOP_LOCK(ap->a_vp, LK_EXCLUSIVE);
free(blkiov, M_SEGMENT);
return error;
default:
return ufs_ioctl(v);
return ufs_fcntl(v);
}
return 0;
}