Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
I have created D13327 on reviews.freebsd.org with a patch that keeps track of # of issued write delegations and allows nfsrv_checkgetattr() to return without acquiring the lock when it is 0. Hopefully kib@, jhb@ or someone who is familiar with the use of the atomic ops in the kernel can review it. (Where the counter code goes should be fine, but I am not sure I got the use of the atomic ops correct.) Hopefully Emmanuel can test the patch to see if it fixes his performance problem. rick From: owner-freebsd-curr...@freebsd.org on behalf of Rick Macklem Sent: Wednesday, November 29, 2017 12:28:05 PM To: Emmanuel Vadot Cc: Konstantin Belousov; FreeBSD Current; freebsd...@freebsd.org Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? Emmanuel Vadot wrote: [stuff snipped] > I haven't test by I can say that it will work, I actually wondered at >first doing that. The problem with this patch is what I tried to >describe in my first and following mails, since you can turn on and off >delegation you can still have delegation (so nfsrv_delegatecnt > 0) >even if the sysctl is == 0. That's why I went to the tunable way, seems >cleaner to me as disabling delegation doesn't really disable them for >current client. Yes, if you have delegations enabled and then disable them, there will be delegations issued for a "while". During that time, the code in nfsrv_checkgetattr() does need to check for them. Since no new delegations will be issued, the outstanding ones will go away when the client chooses to return them. (You can force this on the client by doing a dismount/mount, at least for the FreeBSD client.) Alternately, rebooting the server forces the clients to "recover" delegations and, if they are disabled, that fails. (Actually the recover succeeds, but with a flag set that tells the client it must return them asap.) All the tunable does is make it impossible to disable them without rebooting, but otherwise the effect is the same. I have a patch that keeps a separate counter for write delegations (which are the ones you care about) using atomics to maintain the value. (That will be similar but somewhat better than what this patch does.) rick [lots more snipped] ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org" ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
Emmanuel Vadot wrote: [stuff snipped] > I haven't test by I can say that it will work, I actually wondered at >first doing that. The problem with this patch is what I tried to >describe in my first and following mails, since you can turn on and off >delegation you can still have delegation (so nfsrv_delegatecnt > 0) >even if the sysctl is == 0. That's why I went to the tunable way, seems >cleaner to me as disabling delegation doesn't really disable them for >current client. Yes, if you have delegations enabled and then disable them, there will be delegations issued for a "while". During that time, the code in nfsrv_checkgetattr() does need to check for them. Since no new delegations will be issued, the outstanding ones will go away when the client chooses to return them. (You can force this on the client by doing a dismount/mount, at least for the FreeBSD client.) Alternately, rebooting the server forces the clients to "recover" delegations and, if they are disabled, that fails. (Actually the recover succeeds, but with a flag set that tells the client it must return them asap.) All the tunable does is make it impossible to disable them without rebooting, but otherwise the effect is the same. I have a patch that keeps a separate counter for write delegations (which are the ones you care about) using atomics to maintain the value. (That will be similar but somewhat better than what this patch does.) rick [lots more snipped] ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
Hello Rick, On Tue, 28 Nov 2017 23:18:57 + Rick Macklem wrote: > Did my usual and forgot to attach it. Here's the patch, rick > > > From: Rick Macklem > Sent: Tuesday, November 28, 2017 6:17:13 PM > To: Emmanuel Vadot > Cc: Konstantin Belousov; FreeBSD Current; freebsd...@freebsd.org; Rick Macklem > Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? > > I think the attached patch should fix your performance problem. > It simply checks for nfsrv_delegatecnt != 0 before doing all the > locking stuff in nfsrv_checkgetattr(). > > If this fixes your performance problem (with delegations disabled), > I'll probably add a separate counter for write delegations and > use atomics to increment/decrement it so that it is SMP safe without > acquiring any lock. > > If you can test this, please let me know how it goes? rick I haven't test by I can say that it will work, I actually wondered at first doing that. The problem with this patch is what I tried to describe in my first and following mails, since you can turn on and off delegation you can still have delegation (so nfsrv_delegatecnt > 0) even if the sysctl is == 0. That's why I went to the tunable way, seems cleaner to me as disabling delegation doesn't really disable them for current client. > > From: Rick Macklem > Sent: Tuesday, November 28, 2017 2:09:51 PM > To: Emmanuel Vadot > Cc: Konstantin Belousov; FreeBSD Current; freebsd...@freebsd.org; Rick Macklem > Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? > > Emmanuel Vadot wrote: > >I wrote: > >> Since it defaults to "disabled", I don't see why a tunable would be > >> necessary? > >> (Just do nothing and delegations don't happen. If you want the server > >> to issue delegations, then use the sysctl to turn them on. If you want to > >> turn > >> them off again at the server, reboot the server without setting the > >> sysctl.) > > > >If you need to reboot to make things working again without delegation > >this shouldn't be a sysctl. > Turning them off without rebooting doesn't break anything. > I just wrote it that way since you seemed to want to use a tunable, which > implied rebooting was your preference. > > > > > The reason behind it is recent problem at work on some on our filer > > > > > related to NFS. > > > > > We use NFSv4 without delegation as we never been able to have good > > > > > performance with FreeBSD server and Linux client (we need to do test > > > > > again but that's for later). > > Delegations are almost never useful, especially with Linux clients. > Emmanuel Vadot wrote: > >Can you elaborate ? Reading what delegation are I see that this is > >exactly what I'm looking for to have better performance with NFS for my > >workload (I only have one client per mount point). > Delegations allow the client to do Opens locally without contacting the > server. Unless, the delegation is a write delegation, this only applied > to read-only delegations. Also, since most implementors couldn`t agree > on how to check permissions via the delegation, most client implementations > still do an Access check at open, which is almost as much overhead as the > Open RPC. (For example, Solaris servers always specified an empty ACE in the > delegation, forcing the client to do an Access. I have no idea what the > current Linux serveréclient does. If you capture packets when a Linux > client is mounted with delegations enabled, you could look for RPCs like > Access when > are Opened multiple times. If you see them, then delegations aren`t saving > RPCs. > Also, they are `per file`, so are only useful if the client is Opening the > same file multiple times. > Further, if another client Opens the same file and the first client got a > Write > delegation, then the write delegation must be recalled, which is a lot of > overhead and one of the few cases where the FreeBSD server must exclusively > lock the state lists, forcing all other RPCs related to Open, Close to wait. > > They sounded good in theory and might have worked well if the implementors > had agreed to do them, but that didnèt happen. (Companies pay for servers, > but the > clients donèt get funded so delegation support in the clients are lacking. I > tried > to make them useful in the FreeBSD client, but Ièm not sure I succeeded.) > > > [stuff snipped] > If I understood your original post, you have a performance problem caused > by lock contention, where the server grabs the state lock t
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
Did my usual and forgot to attach it. Here's the patch, rick From: Rick Macklem Sent: Tuesday, November 28, 2017 6:17:13 PM To: Emmanuel Vadot Cc: Konstantin Belousov; FreeBSD Current; freebsd...@freebsd.org; Rick Macklem Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? I think the attached patch should fix your performance problem. It simply checks for nfsrv_delegatecnt != 0 before doing all the locking stuff in nfsrv_checkgetattr(). If this fixes your performance problem (with delegations disabled), I'll probably add a separate counter for write delegations and use atomics to increment/decrement it so that it is SMP safe without acquiring any lock. If you can test this, please let me know how it goes? rick From: Rick Macklem Sent: Tuesday, November 28, 2017 2:09:51 PM To: Emmanuel Vadot Cc: Konstantin Belousov; FreeBSD Current; freebsd...@freebsd.org; Rick Macklem Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? Emmanuel Vadot wrote: >I wrote: >> Since it defaults to "disabled", I don't see why a tunable would be >> necessary? >> (Just do nothing and delegations don't happen. If you want the server >> to issue delegations, then use the sysctl to turn them on. If you want to >> turn >> them off again at the server, reboot the server without setting the sysctl.) > >If you need to reboot to make things working again without delegation >this shouldn't be a sysctl. Turning them off without rebooting doesn't break anything. I just wrote it that way since you seemed to want to use a tunable, which implied rebooting was your preference. > > > > The reason behind it is recent problem at work on some on our filer > > > > related to NFS. > > > > We use NFSv4 without delegation as we never been able to have good > > > > performance with FreeBSD server and Linux client (we need to do test > > > > again but that's for later). > Delegations are almost never useful, especially with Linux clients. Emmanuel Vadot wrote: >Can you elaborate ? Reading what delegation are I see that this is >exactly what I'm looking for to have better performance with NFS for my >workload (I only have one client per mount point). Delegations allow the client to do Opens locally without contacting the server. Unless, the delegation is a write delegation, this only applied to read-only delegations. Also, since most implementors couldn`t agree on how to check permissions via the delegation, most client implementations still do an Access check at open, which is almost as much overhead as the Open RPC. (For example, Solaris servers always specified an empty ACE in the delegation, forcing the client to do an Access. I have no idea what the current Linux serveréclient does. If you capture packets when a Linux client is mounted with delegations enabled, you could look for RPCs like Access when are Opened multiple times. If you see them, then delegations aren`t saving RPCs. Also, they are `per file`, so are only useful if the client is Opening the same file multiple times. Further, if another client Opens the same file and the first client got a Write delegation, then the write delegation must be recalled, which is a lot of overhead and one of the few cases where the FreeBSD server must exclusively lock the state lists, forcing all other RPCs related to Open, Close to wait. They sounded good in theory and might have worked well if the implementors had agreed to do them, but that didnèt happen. (Companies pay for servers, but the clients donèt get funded so delegation support in the clients are lacking. I tried to make them useful in the FreeBSD client, but Ièm not sure I succeeded.) > [stuff snipped] If I understood your original post, you have a performance problem caused by lock contention, where the server grabs the state lock to check for delegations for every Getattr from a client. As below, I think the fix is to add code to check for no delegations issued that does not require acquisition of the state lock. Btw, large numbers of Getattrs will not perform well with delegations. (Again, the client should be able to do Getattr operations locally in the client when it has a delegation for the file, but if the client is not doing that...) I wrote: > > Having a per-mount version of this would be overkill, I think. It would have > to > disable callbacks on the mount point, since there is no way for a client to > say > "don't give me delegations" except disabling callbacks, which the server > requires for delegation issue. > [stuff snipped] > The case where there has never been delegations issued will result in an > empty delegation queue. Maybe this case can be handled without acquiring > the "global
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
I think the attached patch should fix your performance problem. It simply checks for nfsrv_delegatecnt != 0 before doing all the locking stuff in nfsrv_checkgetattr(). If this fixes your performance problem (with delegations disabled), I'll probably add a separate counter for write delegations and use atomics to increment/decrement it so that it is SMP safe without acquiring any lock. If you can test this, please let me know how it goes? rick From: Rick Macklem Sent: Tuesday, November 28, 2017 2:09:51 PM To: Emmanuel Vadot Cc: Konstantin Belousov; FreeBSD Current; freebsd...@freebsd.org; Rick Macklem Subject: Re: Switch vfs.nfsd.issue_delegations to TUNABLE ? Emmanuel Vadot wrote: >I wrote: >> Since it defaults to "disabled", I don't see why a tunable would be >> necessary? >> (Just do nothing and delegations don't happen. If you want the server >> to issue delegations, then use the sysctl to turn them on. If you want to >> turn >> them off again at the server, reboot the server without setting the sysctl.) > >If you need to reboot to make things working again without delegation >this shouldn't be a sysctl. Turning them off without rebooting doesn't break anything. I just wrote it that way since you seemed to want to use a tunable, which implied rebooting was your preference. > > > > The reason behind it is recent problem at work on some on our filer > > > > related to NFS. > > > > We use NFSv4 without delegation as we never been able to have good > > > > performance with FreeBSD server and Linux client (we need to do test > > > > again but that's for later). > Delegations are almost never useful, especially with Linux clients. Emmanuel Vadot wrote: >Can you elaborate ? Reading what delegation are I see that this is >exactly what I'm looking for to have better performance with NFS for my >workload (I only have one client per mount point). Delegations allow the client to do Opens locally without contacting the server. Unless, the delegation is a write delegation, this only applied to read-only delegations. Also, since most implementors couldn`t agree on how to check permissions via the delegation, most client implementations still do an Access check at open, which is almost as much overhead as the Open RPC. (For example, Solaris servers always specified an empty ACE in the delegation, forcing the client to do an Access. I have no idea what the current Linux serveréclient does. If you capture packets when a Linux client is mounted with delegations enabled, you could look for RPCs like Access when are Opened multiple times. If you see them, then delegations aren`t saving RPCs. Also, they are `per file`, so are only useful if the client is Opening the same file multiple times. Further, if another client Opens the same file and the first client got a Write delegation, then the write delegation must be recalled, which is a lot of overhead and one of the few cases where the FreeBSD server must exclusively lock the state lists, forcing all other RPCs related to Open, Close to wait. They sounded good in theory and might have worked well if the implementors had agreed to do them, but that didnèt happen. (Companies pay for servers, but the clients donèt get funded so delegation support in the clients are lacking. I tried to make them useful in the FreeBSD client, but Ièm not sure I succeeded.) > [stuff snipped] If I understood your original post, you have a performance problem caused by lock contention, where the server grabs the state lock to check for delegations for every Getattr from a client. As below, I think the fix is to add code to check for no delegations issued that does not require acquisition of the state lock. Btw, large numbers of Getattrs will not perform well with delegations. (Again, the client should be able to do Getattr operations locally in the client when it has a delegation for the file, but if the client is not doing that...) I wrote: > > Having a per-mount version of this would be overkill, I think. It would have > to > disable callbacks on the mount point, since there is no way for a client to > say > "don't give me delegations" except disabling callbacks, which the server > requires for delegation issue. > [stuff snipped] > The case where there has never been delegations issued will result in an > empty delegation queue. Maybe this case can be handled without acquiring > the "global NFSv4 state lock", which is what sounds like is causing the > performance issue. Maybe a global counter of how many delegations are > issued that is handled by atomic ops. > --> If it is 0, nfsrv_checkgetattr() can just return without acquiring the > lock. > > I'll take a look at this, rick > rick ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
Emmanuel Vadot wrote: >I wrote: >> Since it defaults to "disabled", I don't see why a tunable would be >> necessary? >> (Just do nothing and delegations don't happen. If you want the server >> to issue delegations, then use the sysctl to turn them on. If you want to >> turn >> them off again at the server, reboot the server without setting the sysctl.) > >If you need to reboot to make things working again without delegation >this shouldn't be a sysctl. Turning them off without rebooting doesn't break anything. I just wrote it that way since you seemed to want to use a tunable, which implied rebooting was your preference. > > > > The reason behind it is recent problem at work on some on our filer > > > > related to NFS. > > > > We use NFSv4 without delegation as we never been able to have good > > > > performance with FreeBSD server and Linux client (we need to do test > > > > again but that's for later). > Delegations are almost never useful, especially with Linux clients. Emmanuel Vadot wrote: >Can you elaborate ? Reading what delegation are I see that this is >exactly what I'm looking for to have better performance with NFS for my >workload (I only have one client per mount point). Delegations allow the client to do Opens locally without contacting the server. Unless, the delegation is a write delegation, this only applied to read-only delegations. Also, since most implementors couldn`t agree on how to check permissions via the delegation, most client implementations still do an Access check at open, which is almost as much overhead as the Open RPC. (For example, Solaris servers always specified an empty ACE in the delegation, forcing the client to do an Access. I have no idea what the current Linux serveréclient does. If you capture packets when a Linux client is mounted with delegations enabled, you could look for RPCs like Access when are Opened multiple times. If you see them, then delegations aren`t saving RPCs. Also, they are `per file`, so are only useful if the client is Opening the same file multiple times. Further, if another client Opens the same file and the first client got a Write delegation, then the write delegation must be recalled, which is a lot of overhead and one of the few cases where the FreeBSD server must exclusively lock the state lists, forcing all other RPCs related to Open, Close to wait. They sounded good in theory and might have worked well if the implementors had agreed to do them, but that didnèt happen. (Companies pay for servers, but the clients donèt get funded so delegation support in the clients are lacking. I tried to make them useful in the FreeBSD client, but Ièm not sure I succeeded.) > [stuff snipped] If I understood your original post, you have a performance problem caused by lock contention, where the server grabs the state lock to check for delegations for every Getattr from a client. As below, I think the fix is to add code to check for no delegations issued that does not require acquisition of the state lock. Btw, large numbers of Getattrs will not perform well with delegations. (Again, the client should be able to do Getattr operations locally in the client when it has a delegation for the file, but if the client is not doing that...) I wrote: > > Having a per-mount version of this would be overkill, I think. It would have > to > disable callbacks on the mount point, since there is no way for a client to > say > "don't give me delegations" except disabling callbacks, which the server > requires for delegation issue. > [stuff snipped] > The case where there has never been delegations issued will result in an > empty delegation queue. Maybe this case can be handled without acquiring > the "global NFSv4 state lock", which is what sounds like is causing the > performance issue. Maybe a global counter of how many delegations are > issued that is handled by atomic ops. > --> If it is 0, nfsrv_checkgetattr() can just return without acquiring the > lock. > > I'll take a look at this, rick > rick ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
On Tue, 28 Nov 2017 14:12:38 + Rick Macklem wrote: > Konstantin Belousov wrote: > >On Tue, Nov 28, 2017 at 02:26:10PM +0100, Emmanuel Vadot wrote: > >> On Tue, 28 Nov 2017 13:04:28 +0200 > >> Konstantin Belousov wrote: > >> > >> > On Tue, Nov 28, 2017 at 11:41:36AM +0100, Emmanuel Vadot wrote: > >> > > > >> > > Hello, > >> > > > >> > > I would like to switch the vfs.nfsd.issue_delegations sysctl to a > >> > > tunable. > Since it defaults to "disabled", I don't see why a tunable would be necessary? > (Just do nothing and delegations don't happen. If you want the server > to issue delegations, then use the sysctl to turn them on. If you want to > turn > them off again at the server, reboot the server without setting the sysctl.) If you need to reboot to make things working again without delegation this shouldn't be a sysctl. > > > > The reason behind it is recent problem at work on some on our filer > > > > related to NFS. > > > > We use NFSv4 without delegation as we never been able to have good > > > > performance with FreeBSD server and Linux client (we need to do test > > > > again but that's for later). > Delegations are almost never useful, especially with Linux clients. Can you elaborate ? Reading what delegation are I see that this is exactly what I'm looking for to have better performance with NFS for my workload (I only have one client per mount point). > [stuff snipped] > > > Perhaps make nodeleg per-mount flag ? > The sysctl vfs.nfsd.issue_delegations only affects the server. > If you have a FreeBSD client that is mounting a delegations enabled server and > does not want delegations, just don't run the "nfscbd" daemon on the client. > The only time you want the "nfscbd" daemon running is for delegations and > pNFS layouts. (I suppose there is the case of a client using NFSv4.1/pNFS > against > a server with delegations enabled, but since delegations aren't very useful, > I'd just disable delegations on the server for this case.) > > Having a per-mount version of this would be overkill, I think. It would have > to > disable callbacks on the mount point, since there is no way for a client to > say > "don't give me delegations" except disabling callbacks, which the server > requires for delegation issue. > [stuff snipped] > The case where there has never been delegations issued will result in an > empty delegation queue. Maybe this case can be handled without acquiring > the "global NFSv4 state lock", which is what sounds like is causing the > performance issue. Maybe a global counter of how many delegations are > issued that is handled by atomic ops. > --> If it is 0, nfsrv_checkgetattr() can just return without acquiring the > lock. > > I'll take a look at this, rick > ___ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org" -- Emmanuel Vadot ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
On Tue, 28 Nov 2017 15:40:09 +0200 Konstantin Belousov wrote: > On Tue, Nov 28, 2017 at 02:26:10PM +0100, Emmanuel Vadot wrote: > > On Tue, 28 Nov 2017 13:04:28 +0200 > > Konstantin Belousov wrote: > > > > > On Tue, Nov 28, 2017 at 11:41:36AM +0100, Emmanuel Vadot wrote: > > > > > > > > Hello, > > > > > > > > I would like to switch the vfs.nfsd.issue_delegations sysctl to a > > > > tunable. > > > > The reason behind it is recent problem at work on some on our filer > > > > related to NFS. > > > > We use NFSv4 without delegation as we never been able to have good > > > > performance with FreeBSD server and Linux client (we need to do test > > > > again but that's for later). We recently see all of our filers with NFS > > > > enabled perform pourly, resulting in really bad performance on the > > > > service. > > > > After doing some analyze with pmcstat we've seen that we spend ~50% > > > > of our time in lock delay, called by nfsrv_checkgetattr (See [1]). > > > > This function is only usefull when using delegation, as it search for > > > > some write delegations issued to client, but it's called anyway when > > > > there so no delegation and cause a lot of problem when having a lot of > > > > activities. > > > > We've patched the kernel with the included diff and now everything is > > > > fine (tm) (See [2]). > > > > The problem for upstreaming this patch is that since issue_delegations > > > > is a sysctl we cannot know if the checkgetattr called is needed, hence > > > > the question to switch it to a TUNABLE. Also maybe some other code path > > > > could benefit from it, I haven't read all the source of nfsserver yet. > > > > > > > > Note that I won't MFC the changes as it would break POLA. > > > Perhaps make nodeleg per-mount flag ? > > > The you can check it safely by dereferencing vp->v_mount->mnt_data without > > > acquiring any locks, while the vnode lock is owned and the vnode is not > > > reclaimed. > > > > That won't work with current code. > Why ? > > > Currently if you have delegation enabled and connect one client to a > > mountpoint, then disable delegation, the current client will still have > > delegation while new ones will not. I have not tested restarting nfsd in > > this situation but I suspect that client will behave badly. This is a > > another +1 for making it a tunable I think. > It is up to the filesystem to handle remount, in particular, fs can disable > changing mount options on mount upgrade if the operation is not supported. > In other words, you would do > mount -o nodeleg ... /mnt > and > mount -u -o nonodeleg ... /mnt > needs to return EINVAL. You are talking about client here while I'm talking about server. > > > > > > > > > > Cheers, > > > > > > > > [1] https://people.freebsd.org/~manu/m8.svg > > > > [2] https://people.freebsd.org/~manu/m8-new.svg > > > > > > > > >From 0cba277f406d3ccf3c9e943a3d4e17b529e31c89 Mon Sep 17 00:00:00 2001 > > > > From: Emmanuel Vadot > > > > Date: Fri, 24 Nov 2017 11:17:18 +0100 > > > > Subject: [PATCH 2/4] Do not call nfsrv_checkgetttr if delegation isn't > > > > enable. > > > > > > > > Signed-off-by: Emmanuel Vadot > > > > --- > > > > sys/fs/nfsserver/nfs_nfsdserv.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c > > > > b/sys/fs/nfsserver/nfs_nfsdserv.c index 8102c5810a9..8daf0142360 100644 > > > > --- a/sys/fs/nfsserver/nfs_nfsdserv.c > > > > +++ b/sys/fs/nfsserver/nfs_nfsdserv.c > > > > @@ -54,6 +54,7 @@ extern struct timeval nfsboottime; > > > > extern int nfs_rootfhset; > > > > extern int nfsrv_enable_crossmntpt; > > > > extern int nfsrv_statehashsize; > > > > +extern int nfsrv_issuedelegs; > > > > #endif /* !APPLEKEXT */ > > > > > > > > static int nfs_async = 0; > > > > @@ -240,7 +241,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int > > > > isdgram, if (nd->nd_flag & ND_NFSV4) { > > > > if (NFSISSET_ATTRBIT(&attrbits, > > > > NFSATTRBIT_FILEHANDLE)) nd->nd_repstat = nfsvno_getfh(vp, &fh, p); > > > > - if (!nd->nd_repstat) > > > > + if (nd->nd_repstat == 0 && nfsrv_issuedelegs > > > > == 1) nd->nd_repstat = nfsrv_checkgetattr(nd, vp, > > > > &nva, &attrbits, nd->nd_cred, p); > > > > if (nd->nd_repstat == 0) { > > > > -- > > > > 2.14.2 > > > > > > > > > > > > -- > > > > Emmanuel Vadot > > > > ___ > > > > freebsd...@freebsd.org mailing list > > > > https://lists.freebsd.org/mailman/listinfo/freebsd-fs > > > > To unsubscribe, send any mail to "freebsd-fs-unsubscr...@freebsd.org" > > > ___ > > > freebsd-current@freebsd.org mailing list > > > https://lists.freebsd.org/mailman/listinfo/freebsd-current > > > To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org" > > > > > >
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
Konstantin Belousov wrote: >On Tue, Nov 28, 2017 at 02:26:10PM +0100, Emmanuel Vadot wrote: >> On Tue, 28 Nov 2017 13:04:28 +0200 >> Konstantin Belousov wrote: >> >> > On Tue, Nov 28, 2017 at 11:41:36AM +0100, Emmanuel Vadot wrote: >> > > >> > > Hello, >> > > >> > > I would like to switch the vfs.nfsd.issue_delegations sysctl to a >> > > tunable. Since it defaults to "disabled", I don't see why a tunable would be necessary? (Just do nothing and delegations don't happen. If you want the server to issue delegations, then use the sysctl to turn them on. If you want to turn them off again at the server, reboot the server without setting the sysctl.) > > > The reason behind it is recent problem at work on some on our filer > > > related to NFS. > > > We use NFSv4 without delegation as we never been able to have good > > > performance with FreeBSD server and Linux client (we need to do test > > > again but that's for later). Delegations are almost never useful, especially with Linux clients. [stuff snipped] > > Perhaps make nodeleg per-mount flag ? The sysctl vfs.nfsd.issue_delegations only affects the server. If you have a FreeBSD client that is mounting a delegations enabled server and does not want delegations, just don't run the "nfscbd" daemon on the client. The only time you want the "nfscbd" daemon running is for delegations and pNFS layouts. (I suppose there is the case of a client using NFSv4.1/pNFS against a server with delegations enabled, but since delegations aren't very useful, I'd just disable delegations on the server for this case.) Having a per-mount version of this would be overkill, I think. It would have to disable callbacks on the mount point, since there is no way for a client to say "don't give me delegations" except disabling callbacks, which the server requires for delegation issue. [stuff snipped] The case where there has never been delegations issued will result in an empty delegation queue. Maybe this case can be handled without acquiring the "global NFSv4 state lock", which is what sounds like is causing the performance issue. Maybe a global counter of how many delegations are issued that is handled by atomic ops. --> If it is 0, nfsrv_checkgetattr() can just return without acquiring the lock. I'll take a look at this, rick ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
On Tue, Nov 28, 2017 at 02:26:10PM +0100, Emmanuel Vadot wrote: > On Tue, 28 Nov 2017 13:04:28 +0200 > Konstantin Belousov wrote: > > > On Tue, Nov 28, 2017 at 11:41:36AM +0100, Emmanuel Vadot wrote: > > > > > > Hello, > > > > > > I would like to switch the vfs.nfsd.issue_delegations sysctl to a > > > tunable. > > > The reason behind it is recent problem at work on some on our filer > > > related to NFS. > > > We use NFSv4 without delegation as we never been able to have good > > > performance with FreeBSD server and Linux client (we need to do test > > > again but that's for later). We recently see all of our filers with NFS > > > enabled perform pourly, resulting in really bad performance on the > > > service. > > > After doing some analyze with pmcstat we've seen that we spend ~50% > > > of our time in lock delay, called by nfsrv_checkgetattr (See [1]). > > > This function is only usefull when using delegation, as it search for > > > some write delegations issued to client, but it's called anyway when > > > there so no delegation and cause a lot of problem when having a lot of > > > activities. > > > We've patched the kernel with the included diff and now everything is > > > fine (tm) (See [2]). > > > The problem for upstreaming this patch is that since issue_delegations > > > is a sysctl we cannot know if the checkgetattr called is needed, hence > > > the question to switch it to a TUNABLE. Also maybe some other code path > > > could benefit from it, I haven't read all the source of nfsserver yet. > > > > > > Note that I won't MFC the changes as it would break POLA. > > Perhaps make nodeleg per-mount flag ? > > The you can check it safely by dereferencing vp->v_mount->mnt_data without > > acquiring any locks, while the vnode lock is owned and the vnode is not > > reclaimed. > > That won't work with current code. Why ? > Currently if you have delegation enabled and connect one client to a > mountpoint, then disable delegation, the current client will still have > delegation while new ones will not. I have not tested restarting nfsd in > this situation but I suspect that client will behave badly. This is a > another +1 for making it a tunable I think. It is up to the filesystem to handle remount, in particular, fs can disable changing mount options on mount upgrade if the operation is not supported. In other words, you would do mount -o nodeleg ... /mnt and mount -u -o nonodeleg ... /mnt needs to return EINVAL. > > > > > > > Cheers, > > > > > > [1] https://people.freebsd.org/~manu/m8.svg > > > [2] https://people.freebsd.org/~manu/m8-new.svg > > > > > > >From 0cba277f406d3ccf3c9e943a3d4e17b529e31c89 Mon Sep 17 00:00:00 2001 > > > From: Emmanuel Vadot > > > Date: Fri, 24 Nov 2017 11:17:18 +0100 > > > Subject: [PATCH 2/4] Do not call nfsrv_checkgetttr if delegation isn't > > > enable. > > > > > > Signed-off-by: Emmanuel Vadot > > > --- > > > sys/fs/nfsserver/nfs_nfsdserv.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c > > > b/sys/fs/nfsserver/nfs_nfsdserv.c index 8102c5810a9..8daf0142360 100644 > > > --- a/sys/fs/nfsserver/nfs_nfsdserv.c > > > +++ b/sys/fs/nfsserver/nfs_nfsdserv.c > > > @@ -54,6 +54,7 @@ extern struct timeval nfsboottime; > > > extern int nfs_rootfhset; > > > extern int nfsrv_enable_crossmntpt; > > > extern int nfsrv_statehashsize; > > > +extern int nfsrv_issuedelegs; > > > #endif /* !APPLEKEXT */ > > > > > > static int nfs_async = 0; > > > @@ -240,7 +241,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int > > > isdgram, if (nd->nd_flag & ND_NFSV4) { > > > if (NFSISSET_ATTRBIT(&attrbits, > > > NFSATTRBIT_FILEHANDLE)) nd->nd_repstat = nfsvno_getfh(vp, &fh, p); > > > - if (!nd->nd_repstat) > > > + if (nd->nd_repstat == 0 && nfsrv_issuedelegs > > > == 1) nd->nd_repstat = nfsrv_checkgetattr(nd, vp, > > > &nva, &attrbits, nd->nd_cred, p); > > > if (nd->nd_repstat == 0) { > > > -- > > > 2.14.2 > > > > > > > > > -- > > > Emmanuel Vadot > > > ___ > > > freebsd...@freebsd.org mailing list > > > https://lists.freebsd.org/mailman/listinfo/freebsd-fs > > > To unsubscribe, send any mail to "freebsd-fs-unsubscr...@freebsd.org" > > ___ > > freebsd-current@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-current > > To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org" > > > -- > Emmanuel Vadot ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
On Tue, 28 Nov 2017 13:04:28 +0200 Konstantin Belousov wrote: > On Tue, Nov 28, 2017 at 11:41:36AM +0100, Emmanuel Vadot wrote: > > > > Hello, > > > > I would like to switch the vfs.nfsd.issue_delegations sysctl to a > > tunable. > > The reason behind it is recent problem at work on some on our filer > > related to NFS. > > We use NFSv4 without delegation as we never been able to have good > > performance with FreeBSD server and Linux client (we need to do test > > again but that's for later). We recently see all of our filers with NFS > > enabled perform pourly, resulting in really bad performance on the > > service. > > After doing some analyze with pmcstat we've seen that we spend ~50% > > of our time in lock delay, called by nfsrv_checkgetattr (See [1]). > > This function is only usefull when using delegation, as it search for > > some write delegations issued to client, but it's called anyway when > > there so no delegation and cause a lot of problem when having a lot of > > activities. > > We've patched the kernel with the included diff and now everything is > > fine (tm) (See [2]). > > The problem for upstreaming this patch is that since issue_delegations > > is a sysctl we cannot know if the checkgetattr called is needed, hence > > the question to switch it to a TUNABLE. Also maybe some other code path > > could benefit from it, I haven't read all the source of nfsserver yet. > > > > Note that I won't MFC the changes as it would break POLA. > Perhaps make nodeleg per-mount flag ? > The you can check it safely by dereferencing vp->v_mount->mnt_data without > acquiring any locks, while the vnode lock is owned and the vnode is not > reclaimed. That won't work with current code. Currently if you have delegation enabled and connect one client to a mountpoint, then disable delegation, the current client will still have delegation while new ones will not. I have not tested restarting nfsd in this situation but I suspect that client will behave badly. This is a another +1 for making it a tunable I think. > > > > Cheers, > > > > [1] https://people.freebsd.org/~manu/m8.svg > > [2] https://people.freebsd.org/~manu/m8-new.svg > > > > >From 0cba277f406d3ccf3c9e943a3d4e17b529e31c89 Mon Sep 17 00:00:00 2001 > > From: Emmanuel Vadot > > Date: Fri, 24 Nov 2017 11:17:18 +0100 > > Subject: [PATCH 2/4] Do not call nfsrv_checkgetttr if delegation isn't > > enable. > > > > Signed-off-by: Emmanuel Vadot > > --- > > sys/fs/nfsserver/nfs_nfsdserv.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c > > b/sys/fs/nfsserver/nfs_nfsdserv.c index 8102c5810a9..8daf0142360 100644 > > --- a/sys/fs/nfsserver/nfs_nfsdserv.c > > +++ b/sys/fs/nfsserver/nfs_nfsdserv.c > > @@ -54,6 +54,7 @@ extern struct timeval nfsboottime; > > extern int nfs_rootfhset; > > extern int nfsrv_enable_crossmntpt; > > extern int nfsrv_statehashsize; > > +extern int nfsrv_issuedelegs; > > #endif /* !APPLEKEXT */ > > > > static int nfs_async = 0; > > @@ -240,7 +241,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int > > isdgram, if (nd->nd_flag & ND_NFSV4) { > > if (NFSISSET_ATTRBIT(&attrbits, > > NFSATTRBIT_FILEHANDLE)) nd->nd_repstat = nfsvno_getfh(vp, &fh, p); > > - if (!nd->nd_repstat) > > + if (nd->nd_repstat == 0 && nfsrv_issuedelegs > > == 1) nd->nd_repstat = nfsrv_checkgetattr(nd, vp, > > &nva, &attrbits, nd->nd_cred, p); > > if (nd->nd_repstat == 0) { > > -- > > 2.14.2 > > > > > > -- > > Emmanuel Vadot > > ___ > > freebsd...@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-fs > > To unsubscribe, send any mail to "freebsd-fs-unsubscr...@freebsd.org" > ___ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org" -- Emmanuel Vadot ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Re: Switch vfs.nfsd.issue_delegations to TUNABLE ?
On Tue, Nov 28, 2017 at 11:41:36AM +0100, Emmanuel Vadot wrote: > > Hello, > > I would like to switch the vfs.nfsd.issue_delegations sysctl to a > tunable. > The reason behind it is recent problem at work on some on our filer > related to NFS. > We use NFSv4 without delegation as we never been able to have good > performance with FreeBSD server and Linux client (we need to do test > again but that's for later). We recently see all of our filers with NFS > enabled perform pourly, resulting in really bad performance on the > service. > After doing some analyze with pmcstat we've seen that we spend ~50% > of our time in lock delay, called by nfsrv_checkgetattr (See [1]). > This function is only usefull when using delegation, as it search for > some write delegations issued to client, but it's called anyway when > there so no delegation and cause a lot of problem when having a lot of > activities. > We've patched the kernel with the included diff and now everything is > fine (tm) (See [2]). > The problem for upstreaming this patch is that since issue_delegations > is a sysctl we cannot know if the checkgetattr called is needed, hence > the question to switch it to a TUNABLE. Also maybe some other code path > could benefit from it, I haven't read all the source of nfsserver yet. > > Note that I won't MFC the changes as it would break POLA. Perhaps make nodeleg per-mount flag ? The you can check it safely by dereferencing vp->v_mount->mnt_data without acquiring any locks, while the vnode lock is owned and the vnode is not reclaimed. > > Cheers, > > [1] https://people.freebsd.org/~manu/m8.svg > [2] https://people.freebsd.org/~manu/m8-new.svg > > >From 0cba277f406d3ccf3c9e943a3d4e17b529e31c89 Mon Sep 17 00:00:00 2001 > From: Emmanuel Vadot > Date: Fri, 24 Nov 2017 11:17:18 +0100 > Subject: [PATCH 2/4] Do not call nfsrv_checkgetttr if delegation isn't > enable. > > Signed-off-by: Emmanuel Vadot > --- > sys/fs/nfsserver/nfs_nfsdserv.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c > b/sys/fs/nfsserver/nfs_nfsdserv.c index 8102c5810a9..8daf0142360 100644 > --- a/sys/fs/nfsserver/nfs_nfsdserv.c > +++ b/sys/fs/nfsserver/nfs_nfsdserv.c > @@ -54,6 +54,7 @@ extern struct timeval nfsboottime; > extern int nfs_rootfhset; > extern int nfsrv_enable_crossmntpt; > extern int nfsrv_statehashsize; > +extern int nfsrv_issuedelegs; > #endif /* !APPLEKEXT */ > > static int nfs_async = 0; > @@ -240,7 +241,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int > isdgram, if (nd->nd_flag & ND_NFSV4) { > if (NFSISSET_ATTRBIT(&attrbits, > NFSATTRBIT_FILEHANDLE)) nd->nd_repstat = nfsvno_getfh(vp, &fh, p); > - if (!nd->nd_repstat) > + if (nd->nd_repstat == 0 && nfsrv_issuedelegs > == 1) nd->nd_repstat = nfsrv_checkgetattr(nd, vp, > &nva, &attrbits, nd->nd_cred, p); > if (nd->nd_repstat == 0) { > -- > 2.14.2 > > > -- > Emmanuel Vadot > ___ > freebsd...@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscr...@freebsd.org" ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
Switch vfs.nfsd.issue_delegations to TUNABLE ?
Hello, I would like to switch the vfs.nfsd.issue_delegations sysctl to a tunable. The reason behind it is recent problem at work on some on our filer related to NFS. We use NFSv4 without delegation as we never been able to have good performance with FreeBSD server and Linux client (we need to do test again but that's for later). We recently see all of our filers with NFS enabled perform pourly, resulting in really bad performance on the service. After doing some analyze with pmcstat we've seen that we spend ~50% of our time in lock delay, called by nfsrv_checkgetattr (See [1]). This function is only usefull when using delegation, as it search for some write delegations issued to client, but it's called anyway when there so no delegation and cause a lot of problem when having a lot of activities. We've patched the kernel with the included diff and now everything is fine (tm) (See [2]). The problem for upstreaming this patch is that since issue_delegations is a sysctl we cannot know if the checkgetattr called is needed, hence the question to switch it to a TUNABLE. Also maybe some other code path could benefit from it, I haven't read all the source of nfsserver yet. Note that I won't MFC the changes as it would break POLA. Cheers, [1] https://people.freebsd.org/~manu/m8.svg [2] https://people.freebsd.org/~manu/m8-new.svg >From 0cba277f406d3ccf3c9e943a3d4e17b529e31c89 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Fri, 24 Nov 2017 11:17:18 +0100 Subject: [PATCH 2/4] Do not call nfsrv_checkgetttr if delegation isn't enable. Signed-off-by: Emmanuel Vadot --- sys/fs/nfsserver/nfs_nfsdserv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index 8102c5810a9..8daf0142360 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -54,6 +54,7 @@ extern struct timeval nfsboottime; extern int nfs_rootfhset; extern int nfsrv_enable_crossmntpt; extern int nfsrv_statehashsize; +extern int nfsrv_issuedelegs; #endif /* !APPLEKEXT */ static int nfs_async = 0; @@ -240,7 +241,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram, if (nd->nd_flag & ND_NFSV4) { if (NFSISSET_ATTRBIT(&attrbits, NFSATTRBIT_FILEHANDLE)) nd->nd_repstat = nfsvno_getfh(vp, &fh, p); - if (!nd->nd_repstat) + if (nd->nd_repstat == 0 && nfsrv_issuedelegs == 1) nd->nd_repstat = nfsrv_checkgetattr(nd, vp, &nva, &attrbits, nd->nd_cred, p); if (nd->nd_repstat == 0) { -- 2.14.2 -- Emmanuel Vadot ___ freebsd-current@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"