[Samba-Technical] Wrtiing files from one linux to another linux

Kevin Liao kevinliao at iei.com.tw
Mon Sep 2 02:07:00 GMT 2002


> > > 2. The remote server has successfully received and done the SMBflush
> > > request.
> >
> > When fsync returns (2) has happened. The server has read and responded
to
> > the SMBflush. But we don't know if it actually wrote anything to disk.
> >
> > There is no way the smbfs client can know what the other end does. The
> > protocol "specification" says that it should sync to disk.
>
> Which Samba (as an SMB server) will do, if the 'strict sync' paramater
> is set.  This is off by defult due to excessive usage by some clients.

I look for the source of samba 2.2.5 and find that how smbd will proceed
after receiving SMBflush message.

In smbd/relpy.c:

int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size,
int dum_buffsize)
{
 int outsize = set_message(outbuf,0,0,True);
 files_struct *fsp = file_fsp(inbuf,smb_vwv0);
 START_PROFILE(SMBflush);
 CHECK_FSP(fsp,conn);
 if (!fsp) {
  file_sync_all(conn);
 } else {
  sync_file(conn,fsp);
 }
 DEBUG(3,("flush\n"));
 END_PROFILE(SMBflush);
 return(outsize);
}

Also in smbd/fileio.c:

void sync_file(connection_struct *conn, files_struct *fsp)
{
 if(lp_strict_sync(SNUM(conn)) && fsp->fd != -1) {
  flush_write_cache(fsp, SYNC_FLUSH);
  conn->vfs_ops.fsync(fsp,fsp->fd);
 }
}

Finally it seems that the real syncing will be done if and only if "strict
sync" is set to "yes". Does it imply that calling fsync() is just waste of
time if "strict sync" of the destination share is set to "no"? Thanks for
your helps.

Regards,
Kevin





More information about the samba-technical mailing list