From: Sascha Wildner Date: Tue, 10 Apr 2018 13:11:49 +0000 (+0200) Subject: Move the IOCTLTRIM ioctl to a better header and rename it to DAIOCTRIM. X-Git-Tag: v5.5.0~822 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/32506cfa691f80faa47486d6f94a98ae12387eeb?ds=sidebyside Move the IOCTLTRIM ioctl to a better header and rename it to DAIOCTRIM. really is only for old tty related stuff. Also bump __DragonFly_version, because there is one port which uses IOCTLTRIM currently, i.e. benchmarks/fio. We'll send a patch upstream that switches it to DAIOCTRIM, and once the updated version has hit the /usr/dports tree, I will remove IOCTLTRIM from base. --- diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index f6192370e3..056b5e0f28 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,8 @@ #include #include +#include + #define LBUF 100 static char lbuf[LBUF]; @@ -804,7 +805,7 @@ erase_partition(int i) ioarg[1] = partp->dp_size; ioarg[1] *=secsize; - if (ioctl(fd, IOCTLTRIM, ioarg) < 0) { + if (ioctl(fd, DAIOCTRIM, ioarg) < 0) { printf("Device trim failed\n"); usage (); } diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 71f205b31f..76567a16b4 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -34,7 +34,8 @@ #include #include -#include + +#include /* * make file system for cylinder-group style file systems @@ -1263,7 +1264,7 @@ erfs(off_t byte_start, off_t size) off_t ioarg[2]; ioarg[0] = byte_start; ioarg[1] = size; - if (ioctl(fsi, IOCTLTRIM, ioarg) < 0) { + if (ioctl(fsi, DAIOCTRIM, ioarg) < 0) { err(37, "Device trim failed\n"); } } diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index 0d68d01a17..483a88e4cb 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -35,7 +35,8 @@ #include "hammer_util.h" #include -#include + +#include static int64_t getsize(const char *str, int pw); static int trim_volume(volume_info_t volume); @@ -531,7 +532,7 @@ trim_volume(volume_info_t volume) (unsigned long long)ioarg[0] / 512, (unsigned long long)ioarg[1] / 512); - if (ioctl(volume->fd, IOCTLTRIM, ioarg) == -1) { + if (ioctl(volume->fd, DAIOCTRIM, ioarg) == -1) { err(1, "Trimming %s failed", volume->name); /* not reached */ } diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c index 0a08f79b5f..2f9e843783 100644 --- a/sbin/swapon/swapon.c +++ b/sbin/swapon/swapon.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -49,6 +48,8 @@ #include #include +#include + static void usage(void); static int swap_on_off(char *name, int doingall, int trim, int ask); static char *docrypt(char *fs_spec, int pass); @@ -342,7 +343,7 @@ trim_volume(char * name) printf("Trimming Device:%s, sectors (%llu -%llu)\n",name, (unsigned long long)ioarg[0]/512, (unsigned long long)ioarg[1]/512); - if (ioctl(fd, IOCTLTRIM, ioarg) < 0) { + if (ioctl(fd, DAIOCTRIM, ioarg) < 0) { printf("Device trim failed\n"); usage (); } diff --git a/sys/bus/cam/scsi/scsi_da.c b/sys/bus/cam/scsi/scsi_da.c index 8af7e7a638..9607f43223 100644 --- a/sys/bus/cam/scsi/scsi_da.c +++ b/sys/bus/cam/scsi/scsi_da.c @@ -70,6 +70,7 @@ #include "../cam_xpt_periph.h" #include "../cam_sim.h" +#include "scsi_daio.h" #include "scsi_message.h" #ifndef _KERNEL @@ -420,6 +421,7 @@ daioctl(struct dev_ioctl_args *ap) switch (ap->a_cmd) { case IOCTLTRIM: + case DAIOCTRIM: { bytes_left = del_num[1]; diff --git a/sys/bus/cam/scsi/scsi_daio.h b/sys/bus/cam/scsi/scsi_daio.h new file mode 100644 index 0000000000..fcd965b7c1 --- /dev/null +++ b/sys/bus/cam/scsi/scsi_daio.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2018 The DragonFly Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of The DragonFly Project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific, prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _CAM_SCSI_SCSI_DAIO_H_ +#define _CAM_SCSI_SCSI_DAIO_H_ + +#include + +#define DAIOCTRIM _IOW('C', 128, off_t[2]) + +#endif /* !_CAM_SCSI_SCSI_DAIO_H_ */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 53871f8424..5b8edd1a86 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -172,9 +172,10 @@ * 500200 - 5.2 release * 500300 - 5.3 development * 500301 - rename some public UFS constants + * 500302 - move IOCTLTRIM to a better header and rename it to DAIOCTRIM */ #undef __DragonFly_version -#define __DragonFly_version 500301 /* propagated to newvers */ +#define __DragonFly_version 500302 /* propagated to newvers */ #include