Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 Mar 2017 16:15:18 +0100
From:      Harry Schmalzbauer <freebsd@omnilan.de>
To:        Doug Ambrisko <ambrisko@ambrisko.com>
Cc:        ambrisko@freebsd.org, freebsd-hackers@freebsd.org
Subject:   Re: Fix MNAMELEN or reimplement struct statfs
Message-ID:  <58B6E586.4070507@omnilan.de>
In-Reply-To: <20170228201753.GA99322@ambrisko.com>
References:  <20140415233133.GA14686@ambrisko.com> <5452600C.5030003@omnilan.de> <20141101154004.GA40398@ambrisko.com> <559FD426.3000108@omnilan.de> <20150710154654.GA71708@ambrisko.com> <58B5D571.2010103@omnilan.de> <20170228201753.GA99322@ambrisko.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090904000408010604050402
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Bezüglich Doug Ambrisko's Nachricht vom 28.02.2017 21:17 (localtime):
> On Tue, Feb 28, 2017 at 08:54:25PM +0100, Harry Schmalzbauer wrote:
> |  Bezüglich Doug Ambrisko's Nachricht vom 10.07.2015 17:46 (localtime):
> | > On Fri, Jul 10, 2015 at 04:18:14PM +0200, Harald Schmalzbauer wrote:
> | > | 
> | > | > |  Hello,
> | > | > | 
> | > | > | first sorry for the missing thread references in the header, I'm not
> | > | > | subscribed to hackers@.
> | > | > | 
> | > | > | bdrewery@ pointed me to this discussion in response to my question to
> | > | > | stable@
> | > | > | (http://lists.freebsd.org/pipermail/freebsd-fs/2014-August/019949.html)
> | > | > | 
> | > | > | Last promising post I found:
> | > | > | 
> | > | > | > |/ > I have a new patch at:
> | > | > | > /|/ > 	http://people.freebsd.org/~ambrisko/mount_bigger_2.patch <http://people.freebsd.org/%7Eambrisko/mount_bigger_2.patch>;
> | > | > | > /|/ > that I tested against head.  This should be pretty close to commiting
> | > | > | > /|/ > unless people find some issues with it.
> | > | > | > /|/ 
> | > | > | > /|/ In sys/kern/vfs_mount.c:
> | > | > | > /|/ +		mp->mnt_path = malloc(strlen(fspath), M_MOUNT, M_WAITOK);
> | > | > | > /|/ +		strlcpy((char *)mp->mnt_path, fspath, strlen(fspath));
> | > | > | > /|/ 

…
> | 
> | I'm currently planning to upgrade some machines from 10 to 11-stable, 
> | where I've been happyly running your patch.
> | Any updates on the MNAMELEN front? I nearby read about plans to extend
> | it to ?1000:1088?.
> | 
> | But just for now I'd highly appreciate if you could tell me if you are
> | ware of any objections applying your 
> | mount_bigger_2.patch on 11-stable.
> | 
> | Hope you don't mind if I quote a question from about a year ago:
> | 
> | Bezüglich Harry Schmalzbauer's Nachricht vom 19.11.2015 11:38 (localtime):
> | …
> | >> | I've been using your mount_bigger_2.path for some months without
> | >> | problems, but haven't done any kind of stress test.
> | >> | It just saves my soul in case I have to recover files from
> | >> | (zfs-)snapshots from time to time :-)
> | >
> | > Hello Doug,
> | >
> | > unfortunately, mount_bigger doesn't cover the length restriction for
> | > make_dev_p(), which leads to inaccessable zvols
> | > (g_dev_taste: make_dev_p() failed
> | > (gp->name=zvol/babasP0.1xSATA7k2-0/liveBACKSTOR/zfsREPL/esm-vega/P1/iscsi.redtsdatahdd500@epochp2,
> | > error=63))
> | 
> | Do you have anything handy which solves the make_dev_p() limitation?
> 
> This got lost in my emails.  I need to clean out my home emails.  Too many
> things get lost on I need to go back and look at it but then forget what.
> I was going to look at the this issue when I got a free moment but then
> couldn't find it.
> 
> Do you have a simple repro. to show this.  It would be great if the
> repo. was based on md disk that was ZFS created, mounted and this done
> to.  Then I can repro. it locally and look at it.  I have bhyve setup
> to UEFI PXE boot on my laptop to test things out.

Hi, thanks for your attention!

Due to time constraints I'll need some weeks coming up with that.
But I'm confident I'll find some time to do that and I'll get back to
you, probably in April.


> I'm still waiting for 64 bit inodes to come in which is supposed to help
> with this and make it not needed.  I'm still running this code and need
> to put it on my laptop since I've run into this issue there now.
> 
> It's been nice that people haven't been changing things so the patch still
> applies.  Although it touches a bunch of files it doesn't touch much.  I

Actually it doesn't apply o.o.t.b., but at first it seemed to be rather
easy to me so I started altering, which quickly shows my horrible C
deficiencies.  Unfortunately I don't know anybody who could help me
filling such a simple knowledge gap.

So I ended up with a pratially patch(-patch), which needs some cast
cleanups.

So far I could solve the following problems:
Besides some minor patch-context related changes, there's r275856,
changing fs/ext2fs/ext2_lookup.c.  (u_long)ip got (uintmax)ip, which –
monkey see monkey do – I simply adopted to your patch.

Analogous for (uintmax)va.va_fileid" in sys/security/mac_lomac/mac_lomac.c.


In sys/ufs/ufs/ufs_quota.c, r306553 changed
ITOV(ip)->v_mount->mnt_stat.f_mntonname,quotatypes[i]);
into
ITOVFS(ip)->mnt_stat.f_mntonname,quotatypes[i]);

Again, monkey see monkey do,
-       ITOVFS(ip)->mnt_stat.f_mntonname,
+       ITOVFS(ip)->mnt_path,
is what I modified.


I attached a maximal reduced patch-patch which makes your
mount_bigger_2.patch (as linked at the beginning) RELENG11 applicable.

This leads to the following clang error (Werror)
error: cast from 'const char *' to 'char *' drops const qualifie
r [-Werror,-Wcast-qual]

So one needs to change the following casts:

In sys/fs/cd9660/cd9660_rrip.c:
  (char *)ana

In sys/fs/fuse/fuse_vnops.c:
  (char *)vnode_mount(vp)

In sys/geom/journal/g_journal.c:
  (char *)mp

The last one also needs to be fixed in sys/kern/vfs_mount.c where
strlcpy() and free() are added by the patch.


Since I even wasn't able to find the struct definitions of these I must
give up here, unfortunately I don't have the time to iron out my long
overdue C deficiencies (along with the lack of knowledge how to read
code split over several files).

Hopefully someone can easily solve these cast issues.

-harry

--------------090904000408010604050402
Content-Type: text/x-patch;
 name="mount_bigger_2.patch-RELENG11dif-minimal.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="mount_bigger_2.patch-RELENG11dif-minimal.patch"

--- mount_bigger_2.patch.orig	2017-03-01 14:03:21.937517000 +0100
+++ mount_bigger_2.patch	2017-03-01 14:40:10.943851000 +0100
@@ -8,9 +8,9 @@
  	 */
 -	if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN)
 +	if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MAXPATHLEN)
- 		return (ENAMETOOLONG);
- 
- 	vfsp = vfs_byname_kld(fstype, td, &error);
+ 		error = ENAMETOOLONG;
+ 	if (error == 0 && (vfsp = vfs_byname_kld(fstype, td, &error)) == NULL)
+ 		error = ENODEV;
 Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
 ===================================================================
 --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c	(revision 264468)
@@ -27,9 +27,9 @@
  	    "%s/" ZFS_CTLDIR_NAME "/snapshot/%s",
 -	    dvp->v_vfsp->mnt_stat.f_mntonname, nm);
 +	    dvp->v_vfsp->mnt_path, nm);
- 	err = mount_snapshot(curthread, vpp, "zfs", mountpoint, snapname, 0);
- 	kmem_free(mountpoint, mountpoint_len);
- 	if (err == 0) {
+ 	mutex_exit(&sdp->sd_lock);
+ 
+ 	/*
 Index: sys/fs/cd9660/cd9660_rrip.c
 ===================================================================
 --- sys/fs/cd9660/cd9660_rrip.c	(revision 264468)
@@ -47,16 +47,18 @@
 ===================================================================
 --- sys/fs/ext2fs/ext2_lookup.c	(revision 264468)
 +++ sys/fs/ext2fs/ext2_lookup.c	(working copy)
-@@ -802,10 +802,10 @@
+@@ -802,12 +802,10 @@
  	mp = ITOV(ip)->v_mount;
  	if ((mp->mnt_flag & MNT_RDONLY) == 0)
- 		panic("ext2_dirbad: %s: bad dir ino %lu at offset %ld: %s\n",
--			mp->mnt_stat.f_mntonname, (u_long)ip->i_number,(long)offset, how);
-+			mp->mnt_path, (u_long)ip->i_number,(long)offset, how);
+ 		panic("ext2_dirbad: %s: bad dir ino %ju at offset %ld: %s\n",
+-		    mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number,
+-		    (long)offset, how);
++		    mp->mnt_path, (uintmax_t)ip->i_number, (long)offset, how);
  	else
- 	(void)printf("%s: bad dir ino %lu at offset %ld: %s\n",
--	    mp->mnt_stat.f_mntonname, (u_long)ip->i_number, (long)offset, how);
-+	    mp->mnt_path, (u_long)ip->i_number, (long)offset, how);
+ 		(void)printf("%s: bad dir ino %ju at offset %ld: %s\n",
+-		    mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number,
+-		    (long)offset, how);
++		    mp->mnt_path, (uintmax_t)ip->i_number, (long)offset, how);
  
  }
  
@@ -125,28 +127,6 @@
  
  		error = vn_start_write(NULL, &mp, V_WAIT);
  		if (error != 0) {
-Index: sys/gnu/fs/reiserfs/reiserfs_vfsops.c
-===================================================================
---- sys/gnu/fs/reiserfs/reiserfs_vfsops.c	(revision 264468)
-+++ sys/gnu/fs/reiserfs/reiserfs_vfsops.c	(working copy)
-@@ -309,7 +309,7 @@
- 	reiserfs_log(LOG_DEBUG, "...done\n");
- 
- 	if (sbp != &mp->mnt_stat) {
--		reiserfs_log(LOG_DEBUG, "copying monut point info\n");
-+		reiserfs_log(LOG_DEBUG, "copying mount point info\n");
- 		sbp->f_type = mp->mnt_vfc->vfc_typenum;
- 		bcopy((caddr_t)mp->mnt_stat.f_mntonname,
- 		    (caddr_t)&sbp->f_mntonname[0], MNAMELEN);
-@@ -318,7 +318,7 @@
- 		reiserfs_log(LOG_DEBUG, "  mount from: %s\n",
- 		    sbp->f_mntfromname);
- 		reiserfs_log(LOG_DEBUG, "  mount on:   %s\n",
--		    sbp->f_mntonname);
-+		    mp->mnt_path);
- 		reiserfs_log(LOG_DEBUG, "...done\n");
- 	}
- 
 Index: sys/kern/kern_jail.c
 ===================================================================
 --- sys/kern/kern_jail.c	(revision 264468)
@@ -263,11 +243,11 @@
  		}
  		mtx_lock(&mountlist_mtx);
  		TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) {
--			if (strcmp(mp->mnt_stat.f_mntonname, pathbuf) == 0)
-+			if (strcmp(mp->mnt_path, pathbuf) == 0)
+-			if (strcmp(mp->mnt_stat.f_mntonname, pathbuf) == 0) {
++			if (strcmp(mp->mnt_path, pathbuf) == 0) {
+ 				vfs_ref(mp);
  				break;
- 		}
- 		mtx_unlock(&mountlist_mtx);
+ 			}
 Index: sys/kern/vfs_mountroot.c
 ===================================================================
 --- sys/kern/vfs_mountroot.c	(revision 264468)
@@ -303,15 +283,6 @@
  
  	buf[0] = '\0';
  	mflags = mp->mnt_flag;
-@@ -3406,7 +3406,7 @@
- 			 */
- 			if (strcmp(mp->mnt_vfc->vfc_name, "devfs") != 0) {
- 				printf("unmount of %s failed (",
--				    mp->mnt_stat.f_mntonname);
-+				    mp->mnt_path);
- 				if (error == EBUSY)
- 					printf("BUSY)\n");
- 				else
 Index: sys/security/mac_lomac/mac_lomac.c
 ===================================================================
 --- sys/security/mac_lomac/mac_lomac.c	(revision 264468)
@@ -320,8 +291,8 @@
  		    "mountpount=%s)\n",
  		    subjlabeltext, p->p_pid, pgid, curthread->td_ucred->cr_uid,
  		    p->p_comm, subjtext, actionname, objlabeltext, objname,
--		    va.va_fileid, vp->v_mount->mnt_stat.f_mntonname);
-+		    va.va_fileid, vp->v_mount->mnt_path);
+-		    (uintmax_t)va.va_fileid, vp->v_mount->mnt_stat.f_mntonname);
++		    (uintmax_t)va.va_fileid, vp->v_mount->mnt_path);
  	} else {
  		log(LOG_INFO, "LOMAC: level-%s subject p%dg%du%d:%s demoted to"
  		    " level %s after %s a level-%s %s\n",
@@ -548,8 +519,8 @@
  		 * We need the name for the mount point (also used for
  		 * "last mounted on") copied in. If an error occurs,
  		 * the mount point is discarded by the upper level code.
--		 * Note that vfs_mount() populates f_mntonname for us.
-+		 * Note that vfs_mount() populates mnt_path for us.
+-		 * Note that vfs_mount_alloc() populates f_mntonname for us.
++		 * Note that vfs_mount_alloc() populates mnt_path for us.
  		 */
  		if ((error = ffs_mountfs(devvp, mp, td)) != 0) {
  			vrele(devvp);
@@ -694,8 +665,8 @@
  		DQI_UNLOCK(dq);
  		if (warn)
  			uprintf("\n%s: warning, %s disk quota exceeded\n",
--			    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
-+			    ITOV(ip)->v_mount->mnt_path,
+-			    ITOVFS(ip)->mnt_stat.f_mntonname,
++			    ITOVFS(ip)->mnt_path,
  			    quotatypes[i]);
  	}
  	return (0);
@@ -703,8 +674,8 @@
  			dq->dq_flags |= DQ_BLKS;
  			DQI_UNLOCK(dq);
  			uprintf("\n%s: write failed, %s disk limit reached\n",
--			    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
-+			    ITOV(ip)->v_mount->mnt_path,
+-			    ITOVFS(ip)->mnt_stat.f_mntonname,
++			    ITOVFS(ip)->mnt_path,
  			    quotatypes[type]);
  			return (EDQUOT);
  		}
@@ -712,8 +683,8 @@
  				DQI_UNLOCK(dq);
  				uprintf("\n%s: write failed, %s "
  				    "disk quota exceeded for too long\n",
--				    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
-+				    ITOV(ip)->v_mount->mnt_path,
+-				    ITOVFS(ip)->mnt_stat.f_mntonname,
++				    ITOVFS(ip)->mnt_path,
  				    quotatypes[type]);
  				return (EDQUOT);
  			}
@@ -721,8 +692,8 @@
  		DQI_UNLOCK(dq);
  		if (warn)
  			uprintf("\n%s: warning, %s inode quota exceeded\n",
--			    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
-+			    ITOV(ip)->v_mount->mnt_path,
+-			    ITOVFS(ip)->mnt_stat.f_mntonname,
++			    ITOVFS(ip)->mnt_path,
  			    quotatypes[i]);
  	}
  	return (0);
@@ -730,8 +701,8 @@
  			dq->dq_flags |= DQ_INODS;
  			DQI_UNLOCK(dq);
  			uprintf("\n%s: write failed, %s inode limit reached\n",
--			    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
-+			    ITOV(ip)->v_mount->mnt_path,
+-			    ITOVFS(ip)->mnt_stat.f_mntonname,
++			    ITOVFS(ip)->mnt_path,
  			    quotatypes[type]);
  			return (EDQUOT);
  		}
@@ -739,8 +710,8 @@
  				DQI_UNLOCK(dq);
  				uprintf("\n%s: write failed, %s "
  				    "inode quota exceeded for too long\n",
--				    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
-+				    ITOV(ip)->v_mount->mnt_path,
+-				    ITOVFS(ip)->mnt_stat.f_mntonname,
++				    ITOVFS(ip)->mnt_path,
  				    quotatypes[type]);
  				return (EDQUOT);
  			}

--------------090904000408010604050402--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?58B6E586.4070507>