linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fixing redundant network opens on Linux file creation
@ 2003-01-06 17:25 Steven French
  2003-01-06 18:14 ` Richard Sharpe
  2003-01-06 22:18 ` Marcos Dione
  0 siblings, 2 replies; 23+ messages in thread
From: Steven French @ 2003-01-06 17:25 UTC (permalink / raw)
  To: samba-technical, linux-fsdevel





The creat() system call results (for the Linux kernel) in calls to create
(via vfs_create) then later a call to open (via dentry_open) both of which
eventually end up (for the cifs vfs) doing a network open of the file from
the perspective of the CIFS protocol which degrades performance (because
every creat does one additional open & close than ideal).    In the cifs
protocol file creation is handled as a flag on the open request so create
has a sideeffect of opening the file.   Unfortunately since mknod can call
vfs_create (presumably without immediately afterwards calling open), it
seems like a vfs can't assume that all creates are necessarily going to be
immediately followed by a file open (server file handle leaks would be
possible if such an assumption were made).    smbfs in effect ignores the
subsequent open and the nfs vfs doesn't have this problem because it
doesn't send a remote open request in nfs_open (since v2 and v3 nfs doesn't
really need an open file handle for file based operations like smb/cifs
does).  To improve creat() performance for cifs (without changing namei.c
itself) it seems like there are only two obvious alternatives:

1) Have the cifs vfs ignore subsequent opens of the same file (never have
more than one open per inode - ala smbfs) - which has the disadvantage of
making the open flags (and pid) incorrect for subsequent opens and would
cause server problems with handling byte range locks and potentially causes
problems with other clients accessing a file that was just created via
mknod and therefore should not be considered open anymore.

2) Have the cifs vfs do "lazy close" of files - perhaps using the original
"opbatch" distributing caching mechanism in the smb/cifs protocol (which
cached opens for optimal performance running batch files on network drives)
for distributed cache management (so the client will not cause sharing
violations if other clients try to access the same file).

I prefer the latter but am working on proving that it works now.   Any
other approaches?

Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench@us.ibm.com

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: fixing redundant network opens on Linux file creation
@ 2003-01-06 18:46 Steven French
  2003-01-06 19:26 ` Richard Sharpe
  2003-01-06 20:29 ` Richard Sharpe
  0 siblings, 2 replies; 23+ messages in thread
From: Steven French @ 2003-01-06 18:46 UTC (permalink / raw)
  To: Richard Sharpe; +Cc: samba-technical, linux-fsdevel





On Mon, Jan 06, 2003 at 10:14:10AM -0800, Richard Sharpe wrote:
>
> Isn't creat() a legacy call? I have never used it, and use open(...,
> O_CREAT,...) instead.
>
> Isn't this just a cost of using legacy calls? Why complicate things
overly
> for a call that might not be used all that much?

As Jan indicated, it looks like creat(filename,mode) and open(filename,
O_CREAT | O_TRUNC, mode) follow similar paths in the Linux kernel and both
have the potential "redundant" network file open problem.   In addition the
Connectathon "nfs" (posix file API compliance) tests do issue the creat()
call (a lot) so it is hard to avoid whether even if some considered it
legacy baggage.    Although it would make sense intuitively that passing
O_CREAT on the open system call would (only) invoke the vfs open call (with
the O_CREAT) flag - it first seems to call the vfs create call (and then
invoke open later with the O_CREAT flag set) and the obvious idea of simply
having some network filesystems simply not exporting a create vfs entry
point would result in EACCES being returned (rather than the vfs invoking
the filesystem's open routine specifying the O_CREAT flag as one might
expect).   Uggh.

I too am intrigued about the idea of a "lookup intent" change and better
optimizing the namei.c/open.c file creation code path for this common case
but I didn't see a quick, low risk (for 2.5 kernel) change that would help
network filesystems so am toying with "opbatch/lazy close" ideas.

Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench@us.ibm.com

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: fixing redundant network opens on Linux file creation
@ 2003-01-06 20:50 Steven French
  0 siblings, 0 replies; 23+ messages in thread
From: Steven French @ 2003-01-06 20:50 UTC (permalink / raw)
  To: Richard Sharpe; +Cc: samba-technical, linux-fsdevel





In my informal tests against XP the chaining of the SMB NTCreateX with
SMBClose is beneficial but probably would save less than 15%. The close
cost about 2 ms out of 14 ms total for the sequence of events that a either
the creat or open(O_CREAT) system calls cause but avoiding the second SMB
NTCreateX would save at least double that (an additional approx. 5ms
better).  My informal tests to Samba as the server showed the second open
was also more expensive than the close (about double the cost of the 1st
close).

Richard Sharpe wrote:
>You could turn the CREAT into an OpenAndX with an immediate
>close :-)
>At least it saves you one round trip, but of course, you might
>already be doing that.

Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench@us.ibm.com

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2003-01-09  3:36 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-06 17:25 fixing redundant network opens on Linux file creation Steven French
2003-01-06 18:14 ` Richard Sharpe
2003-01-06 17:59   ` Jan Hudec
2003-01-06 19:42     ` Bryan Henderson
2003-01-06 19:56       ` Jan Harkes
2003-01-06 21:58         ` Bryan Henderson
2003-01-06 21:31       ` Andreas Dilger
2003-01-06 22:23         ` Bryan Henderson
2003-01-06 22:48           ` Andreas Dilger
2003-01-07  1:06             ` Bryan Henderson
2003-01-07 13:19               ` [Lustre-devel] " Mike Shaver
2003-01-07 17:28                 ` Bryan Henderson
2003-01-07 18:50                   ` Andreas Dilger
2003-01-08 17:52                     ` Bryan Henderson
2003-01-08 19:11                       ` Peter Braam
2003-01-09  2:08                         ` Bryan Henderson
2003-01-09  3:36                           ` Peter Braam
2003-01-06 22:18 ` Marcos Dione
2003-01-07  9:35   ` Jan Hudec
  -- strict thread matches above, loose matches on Subject: below --
2003-01-06 18:46 Steven French
2003-01-06 19:26 ` Richard Sharpe
2003-01-06 20:29 ` Richard Sharpe
2003-01-06 20:50 Steven French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).