[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-540-g251df53
James Peach
jorgar at gmail.com
Tue Apr 1 20:11:08 GMT 2008
On 01/04/2008, Jeremy Allison <jra at samba.org> wrote:
> On Tue, Apr 01, 2008 at 08:51:10AM -0700, James Peach wrote:
> >
> > In my Darwin streams patch series, I added a sendfile capability bit
> > to files_struct that any VFS could set to tell the core server code
> > whether sendfile was safe for a particular file.
> >
> > <http://gitweb.samba.org/?p=jpeach/samba.git;a=commitdiff;h=cc48f6f58ae38d41261e9835ab7199994910888a;hp=55bf079402577657d2a11a5a22cd099ead07123d>
> >
> > To me this seems more obvious and general-purpose than poking at base_fsp.
>
>
> Link doesn't resolve.
sigh ..
> Can you send me the diff please ?
sure
From: James Peach <jpeach at apple.com>
Date: Mon, 15 Oct 2007 21:38:33 +0000 (-0700)
Subject: Store sendfile capability per-fsp.
X-Git-Url: http://gitweb.samba.org/?p=jpeach%2Fsamba.git;a=commitdiff_plain;h=cc48f6f58ae38d41261e9835ab7199994910888a;hp=55bf079402577657d2a11a5a22cd099ead07123d
Store sendfile capability per-fsp.
This patch adds a bit to the fsp structure to tell the network send
path whether this file data can safely be sent using the sendfile(2)
system call.
This is a useful facility for VFS authors, since sometimes a VFS
may need to present a non-file object as a file. In this case,
sendfile should not be used.
---
diff --git a/source/include/smb.h b/source/include/smb.h
index 2b20cfa..d0df005 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -520,6 +520,7 @@ typedef struct files_struct {
BOOL modified;
BOOL is_directory;
BOOL is_stat;
+ BOOL is_sendfile_capable;
BOOL aio_write_behind;
BOOL lockdb_clean;
BOOL initial_delete_on_close; /* Only set at NTCreateX if file was created. */
diff --git a/source/modules/vfs_default.c b/source/modules/vfs_default.c
index 286ea1a..503577e 100644
--- a/source/modules/vfs_default.c
+++ b/source/modules/vfs_default.c
@@ -195,6 +195,11 @@ static int vfswrap_open(vfs_handle_struct
*handle, const char *fname,
START_PROFILE(syscall_open);
result = sys_open(fname, flags, mode);
END_PROFILE(syscall_open);
+
+ if (result != -1) {
+ fsp->is_sendfile_capable = lp_use_sendfile(SNUM(handle->conn));
+ }
+
return result;
}
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index fc85cec..cee8d77 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -2218,7 +2218,7 @@ void send_file_readbraw(connection_struct *conn,
files_struct *fsp, SMB_OFF_T st
*/
if ( (chain_size == 0) && (nread > 0) &&
- (fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) {
+ (fsp->wcp == NULL) && (fsp->is_sendfile_capable) ) {
DATA_BLOB header;
_smb_setlen(outbuf,nread);
@@ -2561,7 +2561,7 @@ int send_file_readX(connection_struct *conn,
char *inbuf,char *outbuf,int length
*/
if ((chain_size == 0) && (CVAL(inbuf,smb_vwv0) == 0xFF) &&
- lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
+ (fsp->is_sendfile_capable) && (fsp->wcp == NULL) ) {
SMB_STRUCT_STAT sbuf;
DATA_BLOB header;
--
James Peach | jorgar at gmail.com
More information about the samba-technical
mailing list