summaryrefslogtreecommitdiff
path: root/sys/msdosfs
AgeCommit message (Collapse)Author
2019-08-05Allow concurrent reads of the f_offset field of struct file byanton
serializing both read/write operations using the existing file mutex. The vnode lock still grants exclusive write access to the offset; the mutex is only used to make the actual write atomic and prevent any concurrent reader from observing intermediate values. ok mpi@ visa@
2019-07-25vinvalbuf(9): tlseep -> tsleep_nsec(9); ok millert@cheloha
2019-07-19getblk(9): tsleep(9) -> tsleep_nsec(9); ok visa@cheloha
2019-07-12Revert anton@ changes about read/write unlockingsolene
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2 ok anton@
2019-07-10Make read/write of the f_offset field belonging to struct file MP-safe;anton
as part of the effort to unlock the kernel. Instead of relying on the vnode lock, introduce a dedicated lock per file. Exclusive write access is granted using the new foffset_enter and foffset_leave API. A convenience function foffset_get is also available for threads that only need to read the current offset. The lock acquisition order in vn_write has been changed to match the one in vn_read in order to avoid a potential deadlock. This change also gets rid of a documented race in vn_read(). Inspired by the FreeBSD implementation. With help and ok mpi@ visa@
2019-01-21Introduce a dedicated entry point data structure for file locks. This new dataanton
structure allows for better tracking of pending lock operations which is essential in order to prevent a use-after-free once the underlying vnode is gone. Inspired by the lockf implementation in FreeBSD. ok visa@ Reported-by: syzbot+d5540a236382f50f1dac@syzkaller.appspotmail.com
2018-06-21Drop redundant "node == parent node" checks from VOP_RMDIR()Visa Hankala
implementations. Rely on the VFS layer to do the checking. OK mpi@, helg@
2018-06-07Make callers of VOP_CREATE(9) and VOP_MKNOD(9) responsible forVisa Hankala
unlocking the directory vnode. OK mpi@, helg@
2018-05-27Drop unnecessary `p' parameter from vget(9).Visa Hankala
OK mpi@
2018-05-07Implement VFS read clustering for MSDOSFS, take 3.Martin Pieuchot
With sf@, inputs from krw@, tested by many, ok visa@
2018-05-02Remove proc from the parameters of vn_lock(). The parameter isVisa Hankala
unnecessary because curproc always does the locking. OK mpi@
2018-04-28Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysVisa Hankala
curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
2018-03-28Use RWL_IS_VNODE with locks that are acquired through VOP_LOCK(),Visa Hankala
to appease WITNESS. ext2fs and ffs already use the flag. The same locking pattern appears with other file systems too, so this patch addresses the remaining cases. OK mpi@
2018-02-10Syncronize filesystems to disk when suspending. Each mountpoint's vnodesTheo de Raadt
are pushed to disk. Dangling vnodes (unlinked files still in use) and vnodes undergoing change by long-running syscalls are identified -- and such filesystems are marked dirty on-disk while we are suspended (in case power is lost, a fsck will be required). Filesystems without dangling or busy vnodes are marked clean, resulting in faster boots following "battery died" circumstances. Tested by numerous developers, thanks for the feedback.
2018-01-02Stop assuming <sys/file.h> will pull in fcntl.h when _KERNEL is defined.Philip Guenther
ok millert@ sthen@
2017-12-30Don't pull in <sys/file.h> just to get fcntl.hPhilip Guenther
ok deraadt@ krw@
2017-12-30Delete unnecessary <sys/file.h> includesPhilip Guenther
ok millert@ krw@
2017-12-11In uvm Chuck decided backing store would not be allocated proactivelyTheo de Raadt
for blocks re-fetchable from the filesystem. However at reboot time, filesystems are unmounted, and since processes lack backing store they are killed. Since the scheduler is still running, in some cases init is killed... which drops us to ddb [noted by bluhm]. Solution is to convert filesystems to read-only [proposed by kettenis]. The tale follows: sys_reboot() should pass proc * to MD boot() to vfs_shutdown() which completes current IO with vfs_busy VB_WRITE|VB_WAIT, then calls VFS_MOUNT() with MNT_UPDATE | MNT_RDONLY, soon teaching us that *fs_mount() calls a copyin() late... so store the sizes in vfsconflist[] and move the copyin() to sys_mount()... and notice nfs_mount copyin() is size-variant, so kill legacy struct nfs_args3. Next we learn ffs_mount()'s MNT_UPDATE code is sharp and rusty especially wrt softdep, so fix some bugs adn add ~MNT_SOFTDEP to the downgrade. Some vnodes need a little more help, so tie them to &dead_vnops. ffs_mount calling DIOCCACHESYNC is causing a bit of grief still but this issue is seperate and will be dealt with in time. couple hundred reboots by bluhm and myself, advice from guenther and others at the hut
2017-08-14msdofs: Add new CLUST_END constantStefan Fritsch
(forgot to commit fat.h) Add new CLUST_END and use it as parameter to pcbmap() when searching for end cluster, instead of explicitly passing 0xffff. This fixes potential problem for FAT32, where cluster number may be legally bigger than 0xffff. Also change clusteralloc() so that fillwith is not explicitly passed by caller anymore (there is no need to use anything other than CLUST_EOFE). From NetBSD commit by jdolecek@NetBSD.org ok tb@ mpi@
2017-08-14msdofs: Add new CLUST_END constantStefan Fritsch
Add new CLUST_END and use it as parameter to pcbmap() when searching for end cluster, instead of explicitly passing 0xffff. This fixes potential problem for FAT32, where cluster number may be legally bigger than 0xffff. Also change clusteralloc() so that fillwith is not explicitly passed by caller anymore (there is no need to use anything other than CLUST_EOFE). From NetBSD commit by jdolecek@NetBSD.org ok tb@ mpi@
2017-08-13minor msdosfs tweaksStefan Fritsch
* add to comments for pcbmap() * remove useless ";" ok tb@
2017-06-13Revert 'Implement VFS read clustering for MSDOSFS' againStefan Fritsch
This has again caused regressions, this time when reading from msdosfs. This reverts denode.h 1.31 msdosfs_vnops.c 1.114 Requested by deraadt@
2017-05-29msdosfs & ffs: flush cache if updating mount from r/w to r/oStefan Fritsch
ok deraadt@
2017-05-29Implement VFS read clustering for MSDOSFSStefan Fritsch
This is the reverted commit by mpi@ from msdosfs_vnops.c 1.105 plus some additional tweaks to fix some cluster/block number confusion that lead to regressions when seeking past the end of a file. The original commit message was: The logic used in msdosfs_bmap() to loop calling pcbmap() comes from FreeBSD and is not really efficient but it is good enough since it is only called when generating I/O. With this diff I get a 100% improvement when reading big files from a crappy USB stick. With this and bread_cluster(9) modified to not re-fetch B_CACHED buffers, reading large contiguous files with chunk sizes of MAXPHYS is almost as fast as physio(9) on the same device. For a 'real world' example, when copying music files from a USB stick I see a speed jump from 15MB/s on -current to 24Mb/s with this diff. While here rename some 'lbn' variables into 'cn' to better reflect what we're dealing with. Tested by Mathieu, with support from deraadt@ ok mpi@
2017-04-20Tweak lock inits to make the system runnable with witness(4)Visa Hankala
on amd64 and i386.
2016-10-10Rename BIOS parameter block field from bsPBP to bsBPB. This typoAlexander Bluhm
has been fixed in FreeBSD in 2002. No binary change. From Alexander von Gernler; OK krw@
2016-10-09Do not check the SecPerTrack field of the BPB when mounting a MSDOSAlexander Bluhm
file system. In modern images the field is not set properly and the value is not used anyway. FreeBSD has removed the check already in 2008. From Alexander von Gernler; OK krw@
2016-09-28Kill empty ifdef; ok fcambus@Jeremie Courreges-Anglas
2016-09-07Remove usermount remnants. ok teduMartin Natano
2016-08-30Revert "Implement VFS read clustering for MSDOSFS"Stefan Fritsch
This caused garbage to be written instead of blocks of 0-bytes if a file is extended by seeking past the end. This happens for example when extracting files containing lots of 0-bytes with tar. ok mpi@ Details of original commit: msdosfs_vnops.c revision 1.105 denode.h revision 1.28 date: 2016/01/13 10:00:55; author: mpi; commitid: ru9jHQwQX09BC5Bw; Implement VFS read clustering for MSDOSFS. The logic used in msdosfs_bmap() to loop calling pcbmap() comes from FreeBSD and is not really efficient but it is good enough since it is only called when generating I/O. With this diff I get a 100% improvement when reading big files from a crappy USB stick. With this and bread_cluster(9) modified to not re-fetch B_CACHED buffers, reading large contiguous files with chunk sizes of MAXPHYS is almost as fast as physio(9) on the same device. For a 'real world' example, when copying music files from a USB stick I see a speed jump from 15MB/s on -current to 24Mb/s with this diff. While here rename some 'lbn' variables into 'cn' to better reflect what we're dealing with. Tested by Mathieu, with support from deraadt@
2016-08-13Eliminate pointless casts to qaddr_t of a value being assigned to a void*Philip Guenther
ok kettenis@ krw@ natano@ dlg@ espie@
2016-06-19Remove the lockmgr() API. It is only used by filesystems, where it is aMartin Natano
trivial change to use rrw locks instead. All it needs is LK_* defines for the RW_* flags. tested by naddy and sthen on package building infrastructure input and ok jmc mpi tedu
2016-05-22When pulling an msdos formated umass stick during mount while theAlexander Bluhm
usb stack was busy, the kernel could trigger an uvm fault. There is a race between vop_generic_revoke() and sys_mount() where vgonel() could reset v_specinfo. Then v_specmountpoint is no longer valid. So after sleeping, msdosfs_mountfs() could crash in the error path. The code in the different *_mountfs() functions was inconsistent, implement the same check everywhere. OK krw@ natano@
2016-05-21Remove the -x flag from mount_msdos and always assume the execute bitMartin Natano
for readable directories, while making it subject to the mask option (-m in mount_msdos), so it is still possible to mount with non-executable directories, but with semantics that are easier to comprehend. This makes directory listings with default mount options work again. ok deraadt@
2016-05-21by default, files were made executable. that does not make sense today.Theo de Raadt
noone should be executing a binary from a msdos filesystem, considering the mountpoint tracking permission mode model ok natano krw
2016-04-26Populate all necessary statfs members in .vfs_statfs. cd9660, udf,Martin Natano
msdosfs and nfsv2 don't set f_namemax. ntfs and ext2fs don't set f_namemeax and f_favail. fusefs doesn't set f_mntfromspec, f_favail and f_iosize. Also, make all filesystems use copy_statfs_info(), so that all statfs information is filled in correctly for the (sb != &mp->mnt-stat) case. ok stefan
2016-03-27When pulling and unmounting an umass USB stick, the file systemAlexander Bluhm
could end up in an inconsistent state. The fstype dependent mp->mnt_data was NULL, but the general mp was still listed as a valid mount point. Next access to the file system would crash with a NULL pointer dereference. If closing the device fails, the mount point must go away anyway. There is nothing we can do about it. Remove the workaround for the EIO error in the general unmount code, but do not generate any error in the file system specific unmount functions. OK natano@ beck@
2016-03-19Remove the unused flags argument from VOP_UNLOCK().natano
torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
2016-03-17Set mnt_data to NULL after freeing the file system specific mount point.Alexander Bluhm
OK krw@ natano@ as part of a larger diff
2016-03-14Change a bunch of (<blah> *)0 to NULL.Kenneth R Westerback
ok beck@ deraadt@
2016-02-05Guard against integer overflow when checking whetherStefan Kempf
writing to a file on msdosfs stays within the max. file size. ok kettenis@, krw@
2016-01-27Convert min + uiomovei to ulmin + uiomove.Stefan Kempf
From Martin Natano.
2016-01-13Implement VFS read clustering for MSDOSFS.Martin Pieuchot
The logic used in msdosfs_bmap() to loop calling pcbmap() comes from FreeBSD and is not really efficient but it is good enough since it is only called when generating I/O. With this diff I get a 100% improvement when reading big files from a crappy USB stick. With this and bread_cluster(9) modified to not re-fetch B_CACHED buffers, reading large contiguous files with chunk sizes of MAXPHYS is almost as fast as physio(9) on the same device. For a 'real world' example, when copying music files from a USB stick I see a speed jump from 15MB/s on -current to 24Mb/s with this diff. While here rename some 'lbn' variables into 'cn' to better reflect what we're dealing with. Tested by Mathieu, with support from deraadt@
2015-10-23Fix renaming in the root directory by correctly setting directoryKenneth R Westerback
offset. From Serguey Parkhomovsky via bugs@, in response to problem report from matthieu@. Same fix is in NetBSD for one. ok tedu@
2015-10-23Fix printf() types so kernel compiles with or w/o MSDOSFS_DEBUG.Kenneth R Westerback
e.g. print pointers with %p instead of %08x. No changes outside of MSDOSFS_DEBUG.
2015-10-23Nuke a bunch of leading/embedded/trailing whitespace so the code can beKenneth R Westerback
read without generating spurious headaches.
2015-09-23remove lockmgr_printinfo stubs. from Martin NatanoTed Unangst
2015-04-17Tweaks utimensat/futimens handling to always update ctime, even when bothPhilip Guenther
atime and mtime are UTIME_OMIT (at least for ufs, tmpfs, and ext2fs), and to correctly handle a timestamp of -1. ok millert@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-02-13Include sys/stdint.h for SIZE_MAX instead of relying on the misplacedTodd C. Miller
define in sys/limits.h. OK guenther@