summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2005-09-03 07:19:28 +0000
committerJames Peach <jpeach@samba.org>2005-09-03 07:19:28 +0000
commit016d1669f46f4ce785d3e989c6d87eff2b22acad (patch)
treeefff4136de29936be91bb414edb8cd7b1a4064e2
parentc575e198862a6b3aad677488c486a1922f98ff07 (diff)
downloadsamba-016d1669f46f4ce785d3e989c6d87eff2b22acad.tar.gz
samba-016d1669f46f4ce785d3e989c6d87eff2b22acad.tar.xz
samba-016d1669f46f4ce785d3e989c6d87eff2b22acad.zip
r9985: Move the all the strict sync logic into file_sync().
-rw-r--r--source/smbd/aio.c4
-rw-r--r--source/smbd/fileio.c9
-rw-r--r--source/smbd/files.c2
-rw-r--r--source/smbd/reply.c20
4 files changed, 15 insertions, 20 deletions
diff --git a/source/smbd/aio.c b/source/smbd/aio.c
index d19706ff61a..af1f172b924 100644
--- a/source/smbd/aio.c
+++ b/source/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/source/smbd/fileio.c b/source/smbd/fileio.c
index 76189d114bb..375bfbe7cf3 100644
--- a/source/smbd/fileio.c
+++ b/source/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/source/smbd/files.c b/source/smbd/files.c
index c90c2b627ca..65986e96127 100644
--- a/source/smbd/files.c
+++ b/source/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/source/smbd/reply.c b/source/smbd/reply.c
index e96c3dc01ff..90500066531 100644
--- a/source/smbd/reply.c
+++ b/source/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) {