1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
Commit Graph

44 Commits

Author SHA1 Message Date
Stefan Metzmacher
a63087f527 s3:vfs_fileid: add 'fileid:nolock_all_inodes = BOOL'
This adds the feature of the 'hostname' algorithm,
but provides it for all algorithms, including 'next_module'.

This can be used to deliberately break lock coherency, but
keep the devid/inode pair untouched, as this will only
alter file_id.extid:

  vfs objects = fileid
  fileid:algorithm = next_module
  fileid:nolock_all_inodes = yes

This should be preferred unless someone is already using the
'hostname' algorithm.

Note this is only for testing (or read only shares if at all...)

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
dc478f4897 s3:vfs_fileid: add 'fileid:nolock_all_dirs = BOOL'
This adds the feature of the 'fsname_nodirs' algorithm,
but provides it for all algorithms, including 'next_module'.

This can be used to deliberately break lock coherency, but
keep the devid/inode pair untouched, e.g.

  vfs objects = fileid
  fileid:algorithm = next_module
  fileid:nolock_all_dirs = yes

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
d0d9732acd s3:vfs_fileid: introduce 'fileid:nolock_paths'
This brings much more flexibility compared to:
- 'fsname_norootdir', 'fsname_norootdir_ext',
  which only allow the nolock behavior for the share root
- 'fileid:nolockinode', which only gets a single inode number,
  and ignores the devide id completely.

You can specify path names, which are relative to the shareroot
or absolute.

These names are only evaluated at SMB_VFS_CONNECT() time,
where they are converted into devide and inode pairs.
It means they are completely ignored if the path doesn't
exist yet, or is replaced by a new inode later.

This allows:

- 'fileid:algorithm = fsname_norootdir'
  to be replaced by:
  'fileid:algorithm = fsname' (the default)
  'fileid:nolock_paths = .'

- 'fileid:algorithm = fsname_norootdir_ext'
  to be replaced by:
  'fileid:algorithm = fsname' (the default)
  'fileid:nolock_paths = .'
  'fileid:nolock_max_slots = 18446744073709551615'

And 'fileid:nolockinode = 1234567' and be replaced by
'fileid:nolock_paths = Very/Contended/Path' or
'fileid:nolock_paths = . Very/Contended/Path1 /data/conteded.dir',
if the share root and two additional inodes should be handled
by the 'nolock' behavior.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
c040b811eb s3:vfs_fileid: introduce 'fileid:nolock_max_slots'
This controlls the maximum number of concurrent locking slots
on each host. It specifies the maximal number of locking.tdb
records for a single inode.

It can be used to deliberately break lock coherency not
only between cluster nodes, but also between processes on
each node.

This allows administrators to control the behavior that's
currently only available by 'fsname_norootdir_ext' to
other cases as well.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
f99b617c0c s3:vfs_fileid: also imply the generic nolock logic to the legacy 'hostname' algorithm
That way the file_id.extid is consistenly filled for all cases
where we deliberately break lock coherency.

This will simplify further changes and give administrators more
flexibility.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
48403b0ebb s3:vfs_fileid: also handle 'fsname_nodirs' via fileid_is_nolock_inode()
This means we'll be able to provide the 'nolock' feature for all
directories also with other algorithms than 'fsname' in future.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
72419736bd s3:vfs_fileid: always add the 'nolock' behavior via file_id.extid
file_id.extid was filled with getpid() by 'fsname_norootdir_ext'.

However instead of forcing the existing 'hostname' algorithm for the 'nolock'
case, we'll now generate file_id.extid also based the hostname, vnn
and for 'fsname_norootdir_ext' also the pid.

This simplifies further changes and gives us the ability to generate stable
results for file_id.{devid,inode} based on the main algorithm. This is important
as we have a push_file_id_16() helper function used in places to generate a
stable identifier of the file that is also client visible and might be stored on
stable storage (acl_tdb, xattr_tdb). While the file_id.extid is only used
internally in volatile databases.

Review with: git show --patience

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
a188253829 s3:vfs_fileid: introduce algorithm 'next_module'
This can be use to get just bypass the fileid module for the
common case. But it allows 'fileid:nolockinode' (and in future
other things) to work in order to avoid lock contention
for all 'nolock' inodes.

If we would have started from scratch all the nolock
logic would have been in its own vfs module, just
altering file_id.extid

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
2668700f1e s3:vfs_fileid: maintain an array of nolock inodes
This way 'fsname_norootdir[_ext]' is not overwritten by
'fileid:nolockinode' and both can work independently.

It will also allow us to add more nolock inodes under
other conditions in the following changes.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Stefan Metzmacher
3ec4dddb54 s3:vfs_fileid: move to a single mapping_fn() returning struct file_id
This makes the code much less magic (at least for me) and
it will allow further changes to be made easier.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-05 15:09:35 +00:00
Ralph Boehme
b74653f2cd smbd: add twrp arg to synthetic_smb_fname()
Most places take twrp from a local struct smb_filename variable that the
function is working on. Some don't for various reasons:

o synthetic_smb_fname_split() is only called in very few places where we don't
  expect twrp paths

o implementations of SMB_VFS_GETWD(), SMB_VFS_FS_CAPABILITIES() and
  SMB_VFS_REALPATH() return the systems view of cwd and realpath without twrp info

o VFS modules implementing previous-versions support (vfs_ceph_snapshots,
  vfs_shadow_copy2, vfs_snapper) synthesize raw paths that are passed to VFS NEXT
  functions and therefor do not use twrp

o vfs_fruit: macOS doesn't support VSS

o vfs_recycle: in recycle_create_dir() we need a raw OS path to create a directory

o vfs_virusfilter: a few places where we need raw OS paths

o vfs_xattr_tdb: needs a raw OS path for SMB_VFS_NEXT_STAT()

o printing and rpc server: don't support VSS

o vfs_default_durable_reconnect: no Durable Handles on VSS handles, this might
  be enhances in the future. No idea if Windows supports this.

o get_real_filename_full_scan: hm.... FIXME??

o get_original_lcomp: working on a raw path

o msdfs: doesn't support VSS

o vfs_get_ntquota: synthesizes an smb_filename from ".", so doesn't support VSS
  even though VFS modules implement it

o fd_open: conn_rootdir_fname is a raw path

o msg_file_was_renamed: obvious

o open_np_file: pipes don't support VSS

o Python bindings: get's a raw path from the caller

o set_conn_connectpath: raw path

o set_conn_connectpath: raw path

o torture: gets raw paths from the caller

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
b5c6964a50 s3:param: make "servicename" a substituted option
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-11-27 10:25:37 +00:00
Ralph Boehme
517ec63004 vfs_fileid: add "fsname_norootdir_ext" option
This can be used to deliberately break lock coherency between all smbd processes
in the whole cluster for the root directory of a share.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Sep 25 00:48:45 UTC 2019 on sn-devel-184
2019-09-25 00:48:45 +00:00
Ralph Boehme
929555b7c8 vfs_fileid: add extid mapping hooks
For this always ends up calling fileid_extid_mapping_zero(), so no change in
behaviour. This will change in a subsequent commit.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2019-09-24 23:32:31 +00:00
Ralph Wuerthner
2723d900ef vfs_fileid: fix fsname_norootdir algorithm
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13744

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jan 17 01:36:54 CET 2019 on sn-devel-144
2019-01-17 01:36:54 +01:00
Ralph Wuerthner
12398a2d1d vfs_fileid: fix get_connectpath_ino
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13741

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Jan 15 04:13:15 CET 2019 on sn-devel-144
2019-01-15 04:13:15 +01:00
Volker Lendecke
c6999a248a vfs_fileid: Fix the 32-bit build
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-21 07:08:23 +01:00
Ralph Boehme
7bc329fcc9 vfs_fileid: fix a use after free
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Jan  8 03:16:30 CET 2018 on sn-devel-144
2018-01-08 03:16:30 +01:00
Ralph Boehme
debf8ba799 vfs_fileid: add fileid:algorithm = fsname_norootdir
Based-on-a-patch-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Jan  6 04:41:24 CET 2018 on sn-devel-144
2018-01-06 04:41:24 +01:00
Ralph Boehme
1468dd21c3 vfs_fileid: add fileid:nolockinode parameter
Based-on-a-patch-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Ralph Boehme
b599cb2168 vfs_fileid: add fileid:algorithm = fsname_nodirs
Enabling fileid:algorithm = fsname_nodirs uses the hostname algorithm
for directories and thus breaks cluster lock coherence for directories.

Based-on-a-patch-by: Christian Ambach <ambi@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Ralph Boehme
495c646ec5 vfs_fileid: add fileid:algorithm = hostname
Using fileid:algorithm = hostname makes fileid generate
fileids based on the hostname. This breaks cluster lock coherence.

Based-on-a-patch-by: Christian Ambach <ambi@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Ralph Boehme
6a8764ebcc vfs_fileid: convert dev argument of the device_mapping_fn to SMB_STRUCT_STAT
This is in preperation of adding an additional mapping function that
acts differently depending of the file type. No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Ralph Wuerthner
996249571d vfs_fileid: add "fstype/mntdir deny/allow list" option
When using the fsname or fsid algorithm a stat() and statfs() call is
required for all mounted file systems to generate the file_id. If e.g.
an NFS file system is unresponsive such a call might block and the smbd
process will become unresponsive. Add "fileid:fstype deny",
"fileid:fstype allow", "fileid:mntdir deny", and "fileid:mntdir allow"
options to ignore potentially unresponsive file systems.

See also https://lists.samba.org/archive/samba-technical/2016-January/111553.html
for a discussion about why this is useful.

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Ralph Boehme
326df16173 vfs_fileid: preserve errno in an error code path
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Ralph Boehme
5cce620bc1 vfs_fileid: add a DEBUG message to log dev and inode
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-06 00:07:17 +01:00
Christof Schmitt
4003736a3d vfs: Use static_decl_vfs in all VFS modules
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Dec 18 13:32:00 CET 2017 on sn-devel-144
2017-12-18 13:31:59 +01:00
Andreas Schneider
d11532c446 s3:modules: Avoid setting the sign bit to 1.
Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-08-25 16:15:08 +02:00
Jeremy Allison
306783d6f5 lib: modules: Change XXX_init interface from XXX_init(void) to XXX_init(TALLOC_CTX *)
Not currently used - no logic changes inside.

This will make it possible to pass down a long-lived talloc
context from the loading function for modules to use instead
of having them internally all use talloc_autofree_context()
which is a hidden global.

Updated all known module interface numbers, and added a
WHATSNEW.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Böhme <slow@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Apr 22 01:17:00 CEST 2017 on sn-devel-144
2017-04-22 01:17:00 +02:00
Volker Lendecke
3c0d86e68d vfs_fileid: Fix a signed/unsigned mixup
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-05-19 20:20:20 +02:00
Rusty Russell
fe72740e82 loadparm: make the source3/ lp_ functions take an explicit TALLOC_CTX *.
They use talloc_tos() internally: hoist that up to the callers, some
of whom don't want to us talloc_tos().

A simple patch, but hits a lot of files.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-07-18 15:07:23 +09:30
Richard Sharpe
422494a8e6 vfs: Make function pointer names consistent. They all end in _fn
Autobuild-User: Richard Sharpe <sharpe@samba.org>
Autobuild-Date: Mon Dec 12 04:58:40 CET 2011 on sn-devel-104
2011-12-12 04:58:40 +01:00
Andrew Bartlett
73b377432c s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc()
Using the standard macro makes it easier to move code into common, as
TALLOC_REALLOC_ARRAY isn't standard talloc.

Andrew Bartlett
2011-06-09 12:40:08 +02:00
Jeremy Allison
7d6ebe0de7 More const fixes. Remove CONST_DISCARD. 2011-05-06 01:44:07 +02:00
Günther Deschner
45364f5e69 s3-vfs: include smbd/smbd.h in vfs modules.
Guenther
2011-03-30 01:13:08 +02:00
Günther Deschner
0e771263ee s3-includes: only include system/filesys.h when needed.
Guenther
2011-03-30 01:13:07 +02:00
Jeremy Allison
8303bc49a4 Restructure the connect function code to always call
down to NEXT-> before initializing. This allows us to
do cleanup (by calling DISCONNECT) if initialization
fails. Also fix vfs_acl_xattr which was failing to
call the NEXT connect function.
Jeremy.
2009-11-30 15:53:04 -08:00
Volker Lendecke
033185e2a1 Make the smbd VFS typesafe 2009-07-24 11:42:05 -04:00
Volker Lendecke
49ca690b4b Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STAT
This patch introduces

struct stat_ex {
        dev_t           st_ex_dev;
        ino_t           st_ex_ino;
        mode_t          st_ex_mode;
        nlink_t         st_ex_nlink;
        uid_t           st_ex_uid;
        gid_t           st_ex_gid;
        dev_t           st_ex_rdev;
        off_t           st_ex_size;
        struct timespec st_ex_atime;
        struct timespec st_ex_mtime;
        struct timespec st_ex_ctime;
        struct timespec st_ex_btime; /* birthtime */
        blksize_t       st_ex_blksize;
        blkcnt_t        st_ex_blocks;
};
typedef struct stat_ex SMB_STRUCT_STAT;

It is really large because due to the friendly libc headers playing macro
tricks with fields like st_ino, so I renamed them to st_ex_xxx.

Why this change? To support birthtime, we already have quite a few #ifdef's at
places where it does not really belong. With a stat struct that we control, we
can consolidate the nanosecond timestamps and the birthtime deep in the VFS
stat calls.

At this moment it is triggered by a request to support the birthtime field for
GPFS. GPFS does not extend the system level struct stat, but instead has a
separate call that gets us the additional information beyond posix. Without
being able to do that within the VFS stat calls, that support would have to be
scattered around the main smbd code.

It will very likely break all the onefs modules, but I think the changes will
be reasonably easy to do.
2009-05-26 17:48:23 +02:00
Tim Prouty
6fbebb5369 s3: Modify SMB_VFS_FILE_ID_CREATE to take a stat struct
Since file_id_create_dev is incompatible with the concept of file_ids,
it is now static and in the one file that needs it.
2009-02-19 20:58:01 -08:00
Stefan Metzmacher
554a89df0c s3:vfs_fileid: readd "fileid:algorithm" as option.
"fileid:mapping" is still supported as fallback.

metze
2009-01-16 15:16:58 +01:00
Andrew Tridgell
d609ccbab5 keep compatibility with v3-0-ctdb name for fileid:mapping option
(This used to be commit 2856d2e4a4)
2008-08-13 11:54:01 +02:00
Volker Lendecke
d62563342e Remove connection_struct->mem_ctx, connection_struct is its own parent
(This used to be commit 559180f7d3)
2008-05-05 11:23:13 +02:00
Stefan Metzmacher
d68145a509 r24302: add a module that overloads the file_id_create VFS function
and alters the device id depending on the configured algorithm.

The algorithm is configured via "fileid:algorithm":
- "fsname" (default) uses a uint64 hash over the mount point
- "fsid" uses the fsid returned from statfs()

This is needed for "clustering = yes" on some clusterfilesystems

metze
(This used to be commit 30f9171cca)
2007-10-10 12:29:25 -05:00