summaryrefslogtreecommitdiff
path: root/sys/fs/smbfs/smbfs_node.c
Commit message (Collapse)AuthorAgeFilesLines
* vfs: drop the de facto curthread argument from VOP_INACTIVEMateusz Guzik2020-10-201-2/+1
| | | | Notes: svn path=/head/; revision=366870
* fs: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-2/+2
| | | | Notes: svn path=/head/; revision=365070
* vfs: remove the always-curthread td argument from VOP_RECLAIMMateusz Guzik2020-08-191-1/+0
| | | | Notes: svn path=/head/; revision=364373
* vfs: remove the thread argument from vgetMateusz Guzik2020-08-161-1/+1
| | | | | | | | | | | | | | | | | | It was already asserted to be curthread. Semantic patch: @@ expression arg1, arg2, arg3; @@ - vget(arg1, arg2, arg3) + vget(arg1, arg2) Notes: svn path=/head/; revision=364271
* Rework v_object lifecycle for vnodes.Konstantin Belousov2019-08-291-4/+0
| | | | | | | | | | | | | | | | | | | | | | | Current implementation of vnode_create_vobject() and vnode_destroy_vobject() is written so that it prepared to handle the vm object destruction for live vnode. Practically, no filesystems use this, except for some remnants that were present in UFS till today. One of the consequences of that model is that each filesystem must call vnode_destroy_vobject() in VOP_RECLAIM() or earlier, as result all of them get rid of the v_object in reclaim. Move the call to vnode_destroy_vobject() to vgonel() before VOP_RECLAIM(). This makes v_object stable: either the object is NULL, or it is valid vm object till the vnode reclamation. Remove code from vnode_create_vobject() to handle races with the parallel destruction. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D21412 Notes: svn path=/head/; revision=351598
* sys/fs: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326268
* Replace all remaining calls to vprint(9) with vn_printf(9), and removeEdward Tomasz Napierala2016-08-101-1/+1
| | | | | | | | | the old macro. MFC after: 1 month Notes: svn path=/head/; revision=303924
* Expand the use of stat(2) flags to allow storing some Windows/DOSKenneth D. Merry2013-08-211-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and CIFS file attributes as BSD stat(2) flags. This work is intended to be compatible with ZFS, the Solaris CIFS server's interaction with ZFS, somewhat compatible with MacOS X, and of course compatible with Windows. The Windows attributes that are implemented were chosen based on the attributes that ZFS already supports. The summary of the flags is as follows: UF_SYSTEM: Command line name: "system" or "usystem" ZFS name: XAT_SYSTEM, ZFS_SYSTEM Windows: FILE_ATTRIBUTE_SYSTEM This flag means that the file is used by the operating system. FreeBSD does not enforce any special handling when this flag is set. UF_SPARSE: Command line name: "sparse" or "usparse" ZFS name: XAT_SPARSE, ZFS_SPARSE Windows: FILE_ATTRIBUTE_SPARSE_FILE This flag means that the file is sparse. Although ZFS may modify this in some situations, there is not generally any special handling for this flag. UF_OFFLINE: Command line name: "offline" or "uoffline" ZFS name: XAT_OFFLINE, ZFS_OFFLINE Windows: FILE_ATTRIBUTE_OFFLINE This flag means that the file has been moved to offline storage. FreeBSD does not have any special handling for this flag. UF_REPARSE: Command line name: "reparse" or "ureparse" ZFS name: XAT_REPARSE, ZFS_REPARSE Windows: FILE_ATTRIBUTE_REPARSE_POINT This flag means that the file is a Windows reparse point. ZFS has special handling code for reparse points, but we don't currently have the other supporting infrastructure for them. UF_HIDDEN: Command line name: "hidden" or "uhidden" ZFS name: XAT_HIDDEN, ZFS_HIDDEN Windows: FILE_ATTRIBUTE_HIDDEN This flag means that the file may be excluded from a directory listing if the application honors it. FreeBSD has no special handling for this flag. The name and bit definition for UF_HIDDEN are identical to the definition in MacOS X. UF_READONLY: Command line name: "urdonly", "rdonly", "readonly" ZFS name: XAT_READONLY, ZFS_READONLY Windows: FILE_ATTRIBUTE_READONLY This flag means that the file may not written or appended, but its attributes may be changed. ZFS currently enforces this flag, but Illumos developers have discussed disabling enforcement. The behavior of this flag is different than MacOS X. MacOS X uses UF_IMMUTABLE to represent the DOS readonly permission, but that flag has a stronger meaning than the semantics of DOS readonly permissions. UF_ARCHIVE: Command line name: "uarch", "uarchive" ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE Windows name: FILE_ATTRIBUTE_ARCHIVE The UF_ARCHIVED flag means that the file has changed and needs to be archived. The meaning is same as the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute. msdosfs and ZFS have special handling for this flag. i.e. they will set it when the file changes. sys/param.h: Bump __FreeBSD_version to 1000047 for the addition of new stat(2) flags. chflags.1: Document the new command line flag names (e.g. "system", "hidden") available to the user. ls.1: Reference chflags(1) for a list of file flags and their meanings. strtofflags.c: Implement the mapping between the new command line flag names and new stat(2) flags. chflags.2: Document all of the new stat(2) flags, and explain the intended behavior in a little more detail. Explain how they map to Windows file attributes. Different filesystems behave differently with respect to flags, so warn the application developer to take care when using them. zfs_vnops.c: Add support for getting and setting the UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN, UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags. All of these flags are implemented using attributes that ZFS already supports, so the on-disk format has not changed. ZFS currently doesn't allow setting the UF_REPARSE flag, and we don't really have the other infrastructure to support reparse points. msdosfs_denode.c, msdosfs_vnops.c: Add support for getting and setting UF_HIDDEN, UF_SYSTEM and UF_READONLY in MSDOSFS. It supported SF_ARCHIVED, but this has been changed to be UF_ARCHIVE, which has the same semantics as the DOS archive attribute instead of inverse semantics like SF_ARCHIVED. After discussion with Bruce Evans, change several things in the msdosfs behavior: Use UF_READONLY to indicate whether a file is writeable instead of file permissions, but don't actually enforce it. Refuse to change attributes on the root directory, because it is special in FAT filesystems, but allow most other attribute changes on directories. Don't set the archive attribute on a directory when its modification time is updated. Windows and DOS don't set the archive attribute in that scenario, so we are now bug-for-bug compatible. smbfs_node.c, smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM, UF_READONLY and UF_ARCHIVE in SMBFS. This is similar to changes that Apple has made in their version of SMBFS (as of smb-583.8, posted on opensource.apple.com), but not quite the same. We map SMB_FA_READONLY to UF_READONLY, because UF_READONLY is intended to match the semantics of the DOS readonly flag. The MacOS X code maps both UF_IMMUTABLE and SF_IMMUTABLE to SMB_FA_READONLY, but the immutable flags have stronger meaning than the DOS readonly bit. stat.h: Add definitions for UF_SYSTEM, UF_SPARSE, UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY and UF_HIDDEN. The definition of UF_HIDDEN is the same as the MacOS X definition. Add commented-out definitions of UF_COMPRESSED and UF_TRACKED. They are defined in MacOS X (as of 10.8.2), but we do not implement them (yet). ufs_vnops.c: Add support for getting and setting UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY, UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS. Alphabetize the flags that are supported. These new flags are only stored, UFS does not take any action if the flag is set. Sponsored by: Spectra Logic Reviewed by: bde (earlier version) Notes: svn path=/head/; revision=254627
* Properly use v_data field. This magically worked (even if wrong) untilDavide Italiano2013-06-281-1/+1
| | | | | | | | now because v_data is the first field of the structure, but it's not something we should rely on. Notes: svn path=/head/; revision=252355
* - smbfs_rename() might return an error value without correctly upgradingDavide Italiano2012-11-261-0/+1
| | | | | | | | | | | the vnode use count, and this might cause the kernel to panic if compiled with WITNESS enable. - Be sure to put the '\0' terminator to the rpath string. Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=243548
* - Remove reset of vpp pointer in some places as long as it's not reallyDavide Italiano2012-11-221-3/+0
| | | | | | | | | | | useful and has the side effect of obfuscating the code a bit. - Remove spurious references to simple_lock. Reported by: attilio [1] Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=243397
* Until now, smbfs_fullpath() computed the full path starting from theDavide Italiano2012-11-221-6/+37
| | | | | | | | | | | | | | | | vnode and following back the chain of n_parent pointers up to the root, without acquiring the locks of the n_parent vnodes analyzed during the computation. This is immediately wrong because if the vnode lock is not held there's no guarantee on the validity of the vnode pointer or the data. In order to fix, store the whole path in the smbnode structure so that smbfs_fullpath() can use this information. Discussed with: kib Reported and tested by: pho Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=243396
* Get rid of some old debug code. It provides checks similar to the oneDavide Italiano2012-11-141-28/+0
| | | | | | | | | offered by RedZone so there's no need to keep it. Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=243038
* - Do not put in the mntqueue half-constructed vnodes.Davide Italiano2012-10-311-104/+63
| | | | | | | | | | | | | - Change the code so that it relies on vfs_hash rather than on a home-made hashtable. - There's no need to inline fnv_32_buf(). Reviewed by: delphij Tested by: pho Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=242387
* Fix panic due to page faults while in kernel mode, under conditions ofDavide Italiano2012-10-311-4/+6
| | | | | | | | | | | | VM pressure. The reason is that in some codepaths pointers to stack variables were passed from one thread to another. In collaboration with: pho Reported by: pho's stress2 suite Sponsored by: iXsystems inc. Notes: svn path=/head/; revision=242386
* Simply error handling by moving the allocation of np down to where it isChristian Brueffer2012-07-161-8/+6
| | | | | | | | | | actually used. While here, improve style a little. Submitted by: mjg MFC after: 2 weeks Notes: svn path=/head/; revision=238539
* Save a bzero() by using M_ZERO.Christian Brueffer2012-07-151-2/+1
| | | | | | | | Obtained from: Dragonfly BSD (change 4faaf07c3d7ddd120deed007370aaf4d90b72ebb) MFC after: 2 weeks Notes: svn path=/head/; revision=238491
* Remove unused thread argument to vrecycle().Edward Tomasz Napierala2012-04-231-1/+1
| | | | | | | Reviewed by: kib Notes: svn path=/head/; revision=234607
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.Ed Schouten2011-11-071-1/+1
| | | | | | | This means that their use is restricted to a single C file. Notes: svn path=/head/; revision=227293
* Add dedicated routines to toggle lockmgr flags such as LK_NOSHARE andJohn Baldwin2010-08-201-1/+1
| | | | | | | | | | | | | | | LK_CANRECURSE after a lock is created. Use them to implement macros that otherwise manipulated the flags directly. Assert that the associated lockmgr lock is exclusively locked by the current thread when manipulating these flags to ensure the flag updates are safe. This last change required some minor shuffling in a few filesystems to exclusively lock a brand new vnode slightly earlier. Reviewed by: kib MFC after: 3 days Notes: svn path=/head/; revision=211531
* Switch to our preferred 2-clause BSD license.Joel Dahl2010-04-071-6/+0
| | | | | | | Approved by: bp Notes: svn path=/head/; revision=206361
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-231-5/+5
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Initialize va_rdev to NODEV instead of 0 or VNOVAL in VOP_GETATTR().Konstantin Belousov2008-09-201-1/+1
| | | | | | | | | | | | NODEV is more appropriate when va_rdev doesn't have a meaningful value. Submitted by: Jaakko Heinonen <jh saunalahti fi> Suggested by: bde Discussed on: freebsd-fs MFC after: 1 month Notes: svn path=/head/; revision=183214
* Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed threadAttilio Rao2008-08-281-2/+2
| | | | | | | | | was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com> Notes: svn path=/head/; revision=182371
* Remove unused 'td' arguments from smbfs_hash_lock() andRobert Watson2008-07-011-9/+9
| | | | | | | | | smbfs_hash_unlock(). MFC after: 3 days Notes: svn path=/head/; revision=180139
* Replace lockmgr lock protecting smbfs node hash table with sx lock.Robert Watson2008-03-021-5/+3
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=176744
* Introduce some functions in the vnode locks namespace and in the ffsAttilio Rao2008-02-241-1/+1
| | | | | | | | | | | | | | | | | | namespace in order to handle lockmgr fields in a controlled way instead than spreading all around bogus stubs: - VN_LOCK_AREC() allows lock recursion for a specified vnode - VN_LOCK_ASHARE() allows lock sharing for a specified vnode In FFS land: - BUF_AREC() allows lock recursion for a specified buffer lock - BUF_NOREC() disallows recursion for a specified buffer lock Side note: union_subr.c::unionfs_node_update() is the only other function directly handling lockmgr fields. As this is not simple to fix, it has been left behind as "sole" exception. Notes: svn path=/head/; revision=176519
* Cleanup lockmgr interface and exported KPI:Attilio Rao2008-01-241-3/+4
| | | | | | | | | | | | | | | | | | | | | | | - Remove the "thread" argument from the lockmgr() function as it is always curthread now - Axe lockcount() function as it is no longer used - Axe LOCKMGR_ASSERT() as it is bogus really and no currently used. Hopefully this will be soonly replaced by something suitable for it. - Remove the prototype for dumplockinfo() as the function is no longer present Addictionally: - Introduce a KASSERT() in lockstatus() in order to let it accept only curthread or NULL as they should only be passed - Do a little bit of style(9) cleanup on lockmgr.h KPI results heavilly broken by this change, so manpages and FreeBSD_version will be modified accordingly by further commits. Tested by: matteo Notes: svn path=/head/; revision=175635
* vn_lock() is currently only used with the 'curthread' passed as argument.Attilio Rao2008-01-101-1/+1
| | | | | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com> Notes: svn path=/head/; revision=175202
* Where I previously removed calls to kdb_enter(), now remove include ofRobert Watson2007-05-291-1/+0
| | | | | | | | | kdb.h. Pointed out by: bde Notes: svn path=/head/; revision=170093
* Rather than entering the debugger via kdb_enter() when detecting memoryRobert Watson2007-05-271-12/+6
| | | | | | | corruption under SMBUFS_NAME_DEBUG, panic() with the same error message. Notes: svn path=/head/; revision=170015
* Make insmntque() externally visibile and allow it to fail (e.g. duringTor Egge2007-03-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | late stages of unmount). On failure, the vnode is recycled. Add insmntque1(), to allow for file system specific cleanup when recycling vnode on failure. Change getnewvnode() to no longer call insmntque(). Previously, embryonic vnodes were put onto the list of vnode belonging to a file system, which is unsafe for a file system marked MPSAFE. Change vfs_hash_insert() to no longer lock the vnode. The caller now has that responsibility. Change most file systems to lock the vnode and call insmntque() or insmntque1() after a new vnode has been sufficiently setup. Handle failed insmntque*() calls by propagating errors to callers, possibly after some file system specific cleanup. Approved by: re (kensmith) Reviewed by: kib In collaboration with: kib Notes: svn path=/head/; revision=167497
* Create a bidirectional mapping of the DOS 'read only' attributeBoris Popov2006-11-051-0/+3
| | | | | | | | | | | to the 'w' flag. PR: kern/77958 Submitted by: ghozzy gmail com MFC after: 1 month Notes: svn path=/head/; revision=163993
* I ran into an nfs client panic a couple of times in a row over theAlfred Perlstein2006-01-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | last few days. I tracked it down to the fact that nfs_reclaim() is setting vp->v_data to NULL _before_ calling vnode_destroy_object(). After silence from the mailing list I checked further and discovered that ufs_reclaim() is unique among FreeBSD filesystems for calling vnode_destroy_object() early, long before tossing v_data or much of anything else, for that matter. The rest, including NFS, appear to be identical, as if they were just clones of one original routine. The enclosed patch fixes all file systems in essentially the same way, by moving the call to vnode_destroy_object() to early in the routine (before the call to vfs_hash_remove(), if any). I have only tested NFS, but I've now run for over eighteen hours with the patch where I wouldn't get past four or five without it. Submitted by: Frank Mayhar Requested by: Mohan Srinivasan MFC After: 1 week Notes: svn path=/head/; revision=154487
* Normalize a significant number of kernel malloc type names:Robert Watson2005-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | - Prefer '_' to ' ', as it results in more easily parsed results in memory monitoring tools such as vmstat. - Remove punctuation that is incompatible with using memory type names as file names, such as '/' characters. - Disambiguate some collisions by adding subsystem prefixes to some memory types. - Generally prefer lower case to upper case. - If the same type is defined in multiple architecture directories, attempt to use the same name in additional cases. Not all instances were caught in this change, so more work is required to finish this conversion. Similar changes are required for UMA zone names. Notes: svn path=/head/; revision=151897
* - The VI_DOOMED flag now signals the end of a vnode's relationship withJeff Roberson2005-03-131-2/+1
| | | | | | | | | | | the filesystem. Check that rather than VI_XLOCK. - VOP_INACTIVE should no longer drop the vnode lock. - The vnode lock is required around calls to vrecycle() and vgone(). Sponsored by: Isilon Systems, Inc. Notes: svn path=/head/; revision=143513
* don't call vprint with NULL.Poul-Henning Kamp2005-02-101-1/+1
| | | | Notes: svn path=/head/; revision=141619
* Make filesystems get rid of their own vnodes vnode_pager object inPoul-Henning Kamp2005-01-281-0/+1
| | | | | | | VOP_RECLAIM(). Notes: svn path=/head/; revision=140939
* Remove unused argument to vrecycle()Poul-Henning Kamp2005-01-281-1/+1
| | | | Notes: svn path=/head/; revision=140936
* Eliminate unused and constant arguments to smbfs_vinvalbuf()Poul-Henning Kamp2005-01-141-1/+1
| | | | Notes: svn path=/head/; revision=140223
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139776
* Convert to nmount. Add omount compat.Poul-Henning Kamp2004-12-061-4/+4
| | | | | | | Unpropagate the sm_args function into the runtime part. Notes: svn path=/head/; revision=138490
* Back when VOP_* was introduced, we did not have new-style structPoul-Henning Kamp2004-12-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initializations but we did have lofty goals and big ideals. Adjust to more contemporary circumstances and gain type checking. Replace the entire vop_t frobbing thing with properly typed structures. The only casualty is that we can not add a new VOP_ method with a loadable module. History has not given us reason to belive this would ever be feasible in the the first place. Eliminate in toto VOCALL(), vop_t, VNODEOP_SET() etc. Give coda correct prototypes and function definitions for all vop_()s. Generate a bit more data from the vnode_if.src file: a struct vop_vector and protype typedefs for all vop methods. Add a new vop_bypass() and make vop_default be a pointer to another struct vop_vector. Remove a lot of vfs_init since vop_vector is ready to use from the compiler. Cast various vop_mumble() to void * with uppercase name, for instance VOP_PANIC, VOP_NULL etc. Implement VCALL() by making vdesc_offset the offsetof() the relevant function pointer in vop_vector. This is disgusting but since the code is generated by a script comparatively safe. The alternative for nullfs etc. would be much worse. Fix up all vnode method vectors to remove casts so they become typesafe. (The bulk of this is generated by scripts) Notes: svn path=/head/; revision=138290
* Update for the KDB framework:Marcel Moolenaar2004-07-101-3/+4
| | | | | | | o Call kdb_enter() instead of Debugger(). Notes: svn path=/head/; revision=131924
* Fixes problems that occurred when a file was removed and a directoryTim J. Robbins2004-02-101-0/+17
| | | | | | | | | | | | | | | | | | | created with the same name, and vice versa: - Immediately recycle vnodes of files & directories that have been deleted or renamed. - When looking an entry in the VFS name cache or smbfs's private cache, make sure the vnode type is consistent with the type of file the server thinks it is, and re-create the vnode if it isn't. The alternative to this is to recycle vnodes unconditionally when their use count drops to 0, but this would make all the caching we do mostly useless. PR: 62342 MFC after: 2 weeks Notes: svn path=/head/; revision=125637
* In smbfs_inactive(), only invalidate the node's attribute cache if weTim J. Robbins2004-01-041-1/+1
| | | | | | | had to send a file close request to the server. Notes: svn path=/head/; revision=124115
* - Don't cache_purge() in *_reclaim routines. vclean() does it for us soJeff Roberson2003-10-051-1/+0
| | | | | | | this is redundant. Notes: svn path=/head/; revision=120775
* Send the close request to the SMB server in smbfs_inactive(), instead ofTim J. Robbins2003-06-171-6/+17
| | | | | | | | | | | smbfs_close(). This fixes paging to and from mmap()'d regions of smbfs files after the descriptor has been closed, and makes thttpd, GNU ld, and perhaps more things work that depend on being able to do this. PR: 48291 Notes: svn path=/head/; revision=116486
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-3/+3
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-3/+3
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623