diff options
author | James Peach <jpeach@samba.org> | 2005-09-03 07:19:28 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:03:30 -0500 |
commit | 93954d6390370331731bda5fcf251dc0a796c744 (patch) | |
tree | 809cb1d0377237d21df08dbc7a25c56d9fbc175a | |
parent | 3c82e4cd444d34e0a0ca24fec2e70bad6d9ee6b4 (diff) | |
download | samba-93954d6390370331731bda5fcf251dc0a796c744.tar.gz samba-93954d6390370331731bda5fcf251dc0a796c744.tar.bz2 samba-93954d6390370331731bda5fcf251dc0a796c744.zip |
r9985: Move the all the strict sync logic into file_sync().
(This used to be commit cc680bbe22b8bfc5a1900f11c2cbaeca3a9f9922)
-rw-r--r-- | source3/smbd/aio.c | 4 | ||||
-rw-r--r-- | source3/smbd/fileio.c | 9 | ||||
-rw-r--r-- | source3/smbd/files.c | 2 | ||||
-rw-r--r-- | source3/smbd/reply.c | 20 |
4 files changed, 15 insertions, 20 deletions
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index d19706ff61..af1f172b92 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -475,9 +475,7 @@ Wanted %u bytes but only wrote %d\n", fsp->fsp_name, (unsigned int)numtowrite, ( } DEBUG(3,("handle_aio_write: fnum=%d num=%d wrote=%d\n", fsp->fnum, (int)numtowrite, (int)nwritten)); - if (lp_syncalways(SNUM(fsp->conn)) || write_through) { - sync_file(fsp->conn,fsp); - } + sync_file(fsp->conn,fsp, write_through); } show_msg(outbuf); diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 76189d114b..375bfbe7cf 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -834,15 +834,18 @@ ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason) sync a file ********************************************************************/ -void sync_file(connection_struct *conn, files_struct *fsp) +void sync_file(connection_struct *conn, files_struct *fsp, BOOL write_through) { - if(lp_strict_sync(SNUM(conn)) && fsp->fh->fd != -1) { + if (fsp->fh->fd == -1) + return; + + if (lp_strict_sync(SNUM(conn)) && + (lp_syncalways(SNUM(conn)) || write_through)) { flush_write_cache(fsp, SYNC_FLUSH); SMB_VFS_FSYNC(fsp,fsp->fh->fd); } } - /************************************************************ Perform a stat whether a valid fd or not. ************************************************************/ diff --git a/source3/smbd/files.c b/source3/smbd/files.c index c90c2b627c..65986e9612 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -427,7 +427,7 @@ void file_sync_all(connection_struct *conn) for (fsp=Files;fsp;fsp=next) { next=fsp->next; if ((conn == fsp->conn) && (fsp->fh->fd != -1)) { - sync_file(conn,fsp); + sync_file(conn, fsp, True /* write through */); } } } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index e96c3dc01f..9050006653 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2786,8 +2786,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size, SSVAL(outbuf,smb_vwv0,total_written); - if ((lp_syncalways(SNUM(conn)) || write_through) && lp_strict_sync(SNUM(conn))) - sync_file(conn,fsp); + sync_file(conn, fsp, write_through); DEBUG(3,("writebraw2 fnum=%d start=%.0f num=%d wrote=%d\n", fsp->fnum, (double)startpos, (int)numtowrite,(int)total_written)); @@ -2852,8 +2851,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, nwritten = write_file(fsp,data,startpos,numtowrite); } - if (lp_syncalways(SNUM(conn))) - sync_file(conn,fsp); + sync_file(conn, fsp, False /* write through */); if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) { END_PROFILE(SMBwriteunlock); @@ -2940,8 +2938,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d } else nwritten = write_file(fsp,data,startpos,numtowrite); - if (lp_syncalways(SNUM(conn))) - sync_file(conn,fsp); + sync_file(conn, fsp, False); if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) { END_PROFILE(SMBwrite); @@ -3068,8 +3065,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng DEBUG(3,("writeX fnum=%d num=%d wrote=%d\n", fsp->fnum, (int)numtowrite, (int)nwritten)); - if (lp_syncalways(SNUM(conn)) || write_through) - sync_file(conn,fsp); + sync_file(conn, fsp, write_through); END_PROFILE(SMBwriteX); return chain_reply(inbuf,outbuf,length,bufsize); @@ -3166,7 +3162,7 @@ int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size, int if (!fsp) { file_sync_all(conn); } else { - sync_file(conn,fsp); + sync_file(conn,fsp, True); } DEBUG(3,("flush\n")); @@ -5433,8 +5429,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size, nwritten = write_file(fsp,data,startpos,numtowrite); - if(lp_syncalways(SNUM(conn)) || write_through) - sync_file(conn,fsp); + sync_file(conn, fsp, write_through); if(nwritten < (ssize_t)numtowrite) { END_PROFILE(SMBwriteBmpx); @@ -5546,8 +5541,7 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz nwritten = write_file(fsp,data,startpos,numtowrite); - if(lp_syncalways(SNUM(conn)) || write_through) - sync_file(conn,fsp); + sync_file(conn, fsp, write_through); if (nwritten < (ssize_t)numtowrite) { if(write_through) { |