Bug 65901 - [smbfs] [patch] smbfs fails fsx write/truncate-down/truncate-up/reread old write +FIX
Summary: [smbfs] [patch] smbfs fails fsx write/truncate-down/truncate-up/reread old wr...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 4.7-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-04-23 00:30 UTC by jonathan
Modified: 2022-10-17 12:40 UTC (History)
0 users

See Also:


Attachments
file.diff (3.31 KB, patch)
2004-04-23 00:30 UTC, jonathan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jonathan 2004-04-23 00:30:19 UTC
	Run fsx with -RW. (smbfs does not implement consistency between
	read-write access on the one hand, and mmap access on the other;
	using fsx -R -W avoids testing for those (known) bugs.)

	When  fsx issues the  sequence of operations:
	    1.  write data, X.
	    2.  truncate file down below X.
	    3.  truncate file back above upper edge of X.
	    4.  read from offset of prior data X

	then smbfs passes back the old prior file content, X,
	when it should instead return zeroes.

Fix: The patch below could be described as a "hot glue gun" approach; but
its also a thorough, suspenders-and-braces fix for this problem
(which, btw, does not occur in the NetBSD version of smbfs.)

I'm not really au-fait with the FreeBSD VM system, so I examined the
FreeBSD-4 NFS client code (taken from FreeBSD 4.7's sys/nfs as at
around April 2002) for the corresponding scenario under NFS;, and
patched similar handling into the smbfs code. it may well be that not
all the changes below are necessary; but they appear sufficient.

This patch also applies cleanly to FreeBSD 4-stable as recent up to as
recent as 4.9-STABLE January 2004; for me, it fixes the reported
problem on all those releases.  (If the problem is already fixed
elsewhere in 4.x, I didn't notice).


The timestamps on the diff below are genuine. Someone more familiar
with the 4-STABLE NFS code might wish to subsequent later fixes into
this patch; or reconstruct a similar fix starting from more recent
4-STABLE NFS code.   I can't speak to FreeBSD-5.


How-To-Repeat: 
	repeat as above using fsx.
Comment 1 Tim Robbins freebsd_committer freebsd_triage 2004-04-23 00:38:21 UTC
Responsible Changed
From-To: freebsd-bugs->tjr

I am the current smbfs maintainer.
Comment 2 Tim Robbins freebsd_committer freebsd_triage 2004-12-19 04:25:45 UTC
Responsible Changed
From-To: tjr->freebsd-bugs

Unassign due to lack of time.
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2009-05-18 05:23:38 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:30 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 5 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:40:44 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>