From owner-svn-src-head@freebsd.org Wed Aug 2 11:06:17 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F4FEDCD3CA; Wed, 2 Aug 2017 11:06:17 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47A64925; Wed, 2 Aug 2017 11:06:17 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v72B67Ap015859 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Aug 2017 14:06:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v72B67Ap015859 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v72B67KD015858; Wed, 2 Aug 2017 14:06:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 2 Aug 2017 14:06:07 +0300 From: Konstantin Belousov To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321920 - head/sys/sys Message-ID: <20170802110607.GC1700@kib.kiev.ua> References: <201708021014.v72AEHEk061037@repo.freebsd.org> <7b1d274f-a531-f788-742a-a8375fe76763@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7b1d274f-a531-f788-742a-a8375fe76763@selasky.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Aug 2017 11:06:17 -0000 On Wed, Aug 02, 2017 at 12:35:47PM +0200, Hans Petter Selasky wrote: > On 08/02/17 12:14, Konstantin Belousov wrote: > > Author: kib > > Date: Wed Aug 2 10:14:17 2017 > > New Revision: 321920 > > URL: https://svnweb.freebsd.org/changeset/base/321920 > > > > Log: > > Change major()/minor() to work with 64bit dev_t. > > > > Since traditional types for the macros values are int, remove the > > cookie trick and just split the dev_t at the word boundary. > > > > Reported by: Victor Stinner > > PR: 221048 > > Sponsored by: The FreeBSD Foundation > > > > Modified: > > head/sys/sys/types.h > > > > Modified: head/sys/sys/types.h > > ============================================================================== > > --- head/sys/sys/types.h Wed Aug 2 10:12:10 2017 (r321919) > > +++ head/sys/sys/types.h Wed Aug 2 10:14:17 2017 (r321920) > > @@ -364,14 +364,9 @@ __bitcount64(__uint64_t _x) > > > > #include > > > > -/* > > - * minor() gives a cookie instead of an index since we don't want to > > - * change the meanings of bits 0-15 or waste time and space shifting > > - * bits 16-31 for devices that don't use them. > > - */ > > -#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ > > -#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ > > -#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ > > +#define major(x) ((int)((dev_t)(x) >> 32)) /* major number */ > > +#define minor(x) ((int)((x) & 0xffffffff)) /* minor number */ > > +#define makedev(x, y) (((dev_t)(x) << 32) | (y)) /* create dev_t */ > > > > /* > > * These declarations belong elsewhere, but are repeated here and in > > > > Hi, > > This change breaks the LinuxKPI: > > > struct linux_cdev * > > linux_find_cdev(const char *name, unsigned major, unsigned minor) > > { > > int unit = MKDEV(major, minor); > > struct cdev *cdev; > > > > dev_lock(); > > LIST_FOREACH(cdev, &linuxcdevsw.d_devs, si_list) { > > struct linux_cdev *ldev = cdev->si_drv1; > > if (dev2unit(cdev) == unit && > > strcmp(kobject_name(&ldev->kobj), name) == 0) { > > break; > > } > > } > > dev_unlock(); > > > > return (cdev != NULL ? cdev->si_drv1 : NULL); > > } So linuxkpi was broken before this commit as well, as I noted in my other reply ? > > You will also need to change cdev->si_drv0 to dev_t and fix the > make_dev() functions too. Why do you think that si_drv0 needs to be changes ? > > > struct cdev { > > void *si_spare0; > > u_int si_flags; > > #define SI_ETERNAL 0x0001 /* never destroyed */ > > #define SI_ALIAS 0x0002 /* carrier of alias name */ > > #define SI_NAMED 0x0004 /* make_dev{_alias} has been called */ > > #define SI_CHEAPCLONE 0x0008 /* can be removed_dev'ed when vnode reclaims */ > > #define SI_CHILD 0x0010 /* child of another struct cdev **/ > > #define SI_DUMPDEV 0x0080 /* is kernel dumpdev */ > > #define SI_CLONELIST 0x0200 /* on a clone list */ > > #define SI_UNMAPPED 0x0400 /* can handle unmapped I/O */ > > #define SI_NOSPLIT 0x0800 /* I/O should not be split up */ > > struct timespec si_atime; > > struct timespec si_ctime; > > struct timespec si_mtime; > > uid_t si_uid; > > gid_t si_gid; > > mode_t si_mode; > > struct ucred *si_cred; /* cached clone-time credential */ > > int si_drv0; > > > Further this update assigns a 64-bit value to tfsid.val[0], which is > 32-bit ?? > > > sys/sys/mount.h:typedef struct fsid { int32_t val[2]; } fsid_t; /* > filesystem id type */ > > sys/kern/vfs_subr.c: tfsid.val[0] = makedev(255, >From my reading if the vfs_getnewfsid() code, it is fine. It ignores the 255-major value, which does not add much sense to the returned value, just that byte 1 is not zero and not 0xff. > > And there are more places like this! I see the use of makedev() in nfsserver, where the change seemingly improve the situation by initializing na_rdev to the full 64 bit value, and in fdescfs, which does not care. > > Did you properly check all uses of makedev() in the kernel before making > this change? > > --HPS