diff mbox

[4/4] mountd: don't automatically add subexports to kernel cache

Message ID 1308063492-30103-5-git-send-email-bfields@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bruce Fields June 14, 2011, 2:58 p.m. UTC
Given a crossmnt export and a child path, search for all mountpoints in
between and add exports for them to the kernel.

This isn't necessary; if the the kernel needs one of the subexports, it
can always ask.

It might be some sort of minor optimization to add exports preemptively.
But if so, why not just add them all?  Why this particular subset?

Given the chance to delete some code I can't justify, I'll take it.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 utils/mountd/cache.c |   42 +-----------------------------------------
 1 files changed, 1 insertions(+), 41 deletions(-)

Comments

Steve Dickson June 22, 2011, 10:30 p.m. UTC | #1
Hey Bruce,

This patch breaks cross mounts... Here is my set up

/home/fs1 two different file systems:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-HomeDirs
                      15236080   9439036   5010612  66% /home
RedHat# df /home/fs1
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-FS1
                      10321208    154468   9642452   2% /home/fs1

The export is:
  /home *(rw,crossmnt,nohide,sec=sys:krb5:krb5i:krb5p)

when I mount from a f15 client
    mount -v -o v3 redhat:/home/fs1/tmp/tophat /mnt/tmp
I get:
    mount.nfs: mount(2): Stale NFS file handle

When I revert the patch, the mount works.

Unfortunately I'm going to be taking the next few days off
so I am not going be able to debug this... So I'm going to 
wait on the entire patch series until we can sort this out...

steved.

On 06/14/2011 10:58 AM, J. Bruce Fields wrote:
> Given a crossmnt export and a child path, search for all mountpoints in
> between and add exports for them to the kernel.
> 
> This isn't necessary; if the the kernel needs one of the subexports, it
> can always ask.
> 
> It might be some sort of minor optimization to add exports preemptively.
> But if so, why not just add them all?  Why this particular subset?
> 
> Given the chance to delete some code I can't justify, I'll take it.
> 
> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> ---
>  utils/mountd/cache.c |   42 +-----------------------------------------
>  1 files changed, 1 insertions(+), 41 deletions(-)
> 
> diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
> index d2ae4563..c77eb27 100644
> --- a/utils/mountd/cache.c
> +++ b/utils/mountd/cache.c
> @@ -945,53 +945,13 @@ static int cache_export_ent(char *domain, struct exportent *exp, char *path)
>  	if (!f)
>  		return -1;
>  
> -	err = dump_to_cache(f, domain, exp->e_path, exp);
> +	err = dump_to_cache(f, domain, path, exp);
>  	if (err) {
>  		xlog(L_WARNING,
>  		     "Cannot export %s, possibly unsupported filesystem or"
>  		     " fsid= required", exp->e_path);
>  	}
>  
> -	while (err == 0 && (exp->e_flags & NFSEXP_CROSSMOUNT) && path) {
> -		/* really an 'if', but we can break out of
> -		 * a 'while' more easily */
> -		/* Look along 'path' for other filesystems
> -		 * and export them with the same options
> -		 */
> -		struct stat stb;
> -		size_t l = strlen(exp->e_path);
> -		__dev_t dev;
> -
> -		if (strlen(path) <= l || path[l] != '/' ||
> -		    strncmp(exp->e_path, path, l) != 0)
> -			break;
> -		if (stat(exp->e_path, &stb) != 0)
> -			break;
> -		dev = stb.st_dev;
> -		while(path[l] == '/') {
> -			char c;
> -			/* errors for submount should fail whole filesystem */
> -			int err2;
> -
> -			l++;
> -			while (path[l] != '/' && path[l])
> -				l++;
> -			c = path[l];
> -			path[l] = 0;
> -			err2 = lstat(path, &stb);
> -			path[l] = c;
> -			if (err2 < 0)
> -				break;
> -			if (stb.st_dev == dev)
> -				continue;
> -			dev = stb.st_dev;
> -			path[l] = 0;
> -			dump_to_cache(f, domain, path, exp);
> -			path[l] = c;
> -		}
> -		break;
> -	}
> -
>  	fclose(f);
>  	return err;
>  }
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bruce Fields June 22, 2011, 10:34 p.m. UTC | #2
On Wed, Jun 22, 2011 at 06:30:32PM -0400, Steve Dickson wrote:
> Hey Bruce,
> 
> This patch breaks cross mounts... Here is my set up
> 
> /home/fs1 two different file systems:
> 
> Filesystem           1K-blocks      Used Available Use% Mounted on
> /dev/mapper/VolGroup00-HomeDirs
>                       15236080   9439036   5010612  66% /home
> RedHat# df /home/fs1
> Filesystem           1K-blocks      Used Available Use% Mounted on
> /dev/mapper/VolGroup00-FS1
>                       10321208    154468   9642452   2% /home/fs1
> 
> The export is:
>   /home *(rw,crossmnt,nohide,sec=sys:krb5:krb5i:krb5p)
> 
> when I mount from a f15 client
>     mount -v -o v3 redhat:/home/fs1/tmp/tophat /mnt/tmp
> I get:
>     mount.nfs: mount(2): Stale NFS file handle
> 
> When I revert the patch, the mount works.

Oh, crap, I didn't check v3.  And, OK, it makes sense that v3 might need
this.

> Unfortunately I'm going to be taking the next few days off
> so I am not going be able to debug this... So I'm going to 
> wait on the entire patch series until we can sort this out...

No problem.  But if you want to apply the rest of the series and drop
just this one patch, that would be fine too.  (That's probably what will
end up being the fix anyway.)

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve Dickson June 27, 2011, 4:36 p.m. UTC | #3
On 06/22/2011 06:34 PM, J. Bruce Fields wrote:
> On Wed, Jun 22, 2011 at 06:30:32PM -0400, Steve Dickson wrote:
>> Hey Bruce,
>>
>> This patch breaks cross mounts... Here is my set up
>>
>> /home/fs1 two different file systems:
>>
>> Filesystem           1K-blocks      Used Available Use% Mounted on
>> /dev/mapper/VolGroup00-HomeDirs
>>                       15236080   9439036   5010612  66% /home
>> RedHat# df /home/fs1
>> Filesystem           1K-blocks      Used Available Use% Mounted on
>> /dev/mapper/VolGroup00-FS1
>>                       10321208    154468   9642452   2% /home/fs1
>>
>> The export is:
>>   /home *(rw,crossmnt,nohide,sec=sys:krb5:krb5i:krb5p)
>>
>> when I mount from a f15 client
>>     mount -v -o v3 redhat:/home/fs1/tmp/tophat /mnt/tmp
>> I get:
>>     mount.nfs: mount(2): Stale NFS file handle
>>
>> When I revert the patch, the mount works.
> 
> Oh, crap, I didn't check v3.  And, OK, it makes sense that v3 might need
> this.
> 
>> Unfortunately I'm going to be taking the next few days off
>> so I am not going be able to debug this... So I'm going to 
>> wait on the entire patch series until we can sort this out...
> 
> No problem.  But if you want to apply the rest of the series and drop
> just this one patch, that would be fine too.  (That's probably what will
> end up being the fix anyway.)
Ok... I just committed the first three patches of this series...

steved.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index d2ae4563..c77eb27 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -945,53 +945,13 @@  static int cache_export_ent(char *domain, struct exportent *exp, char *path)
 	if (!f)
 		return -1;
 
-	err = dump_to_cache(f, domain, exp->e_path, exp);
+	err = dump_to_cache(f, domain, path, exp);
 	if (err) {
 		xlog(L_WARNING,
 		     "Cannot export %s, possibly unsupported filesystem or"
 		     " fsid= required", exp->e_path);
 	}
 
-	while (err == 0 && (exp->e_flags & NFSEXP_CROSSMOUNT) && path) {
-		/* really an 'if', but we can break out of
-		 * a 'while' more easily */
-		/* Look along 'path' for other filesystems
-		 * and export them with the same options
-		 */
-		struct stat stb;
-		size_t l = strlen(exp->e_path);
-		__dev_t dev;
-
-		if (strlen(path) <= l || path[l] != '/' ||
-		    strncmp(exp->e_path, path, l) != 0)
-			break;
-		if (stat(exp->e_path, &stb) != 0)
-			break;
-		dev = stb.st_dev;
-		while(path[l] == '/') {
-			char c;
-			/* errors for submount should fail whole filesystem */
-			int err2;
-
-			l++;
-			while (path[l] != '/' && path[l])
-				l++;
-			c = path[l];
-			path[l] = 0;
-			err2 = lstat(path, &stb);
-			path[l] = c;
-			if (err2 < 0)
-				break;
-			if (stb.st_dev == dev)
-				continue;
-			dev = stb.st_dev;
-			path[l] = 0;
-			dump_to_cache(f, domain, path, exp);
-			path[l] = c;
-		}
-		break;
-	}
-
 	fclose(f);
 	return err;
 }