[SCM] Samba Shared Repository - branch v4-8-test updated

Karolin Seeger kseeger at samba.org
Tue Nov 6 12:45:03 UTC 2018


The branch, v4-8-test has been updated
       via  b51ef80 torture: Fix the clang build
       via  0eebb6e vfs_fruit: let fruit_open_meta() with O_CREAT return a fake-fd
       via  cbbd530 vfs_fruit: don't check for delete-on-close on the FinderInfo stream
       via  80c9567 vfs_fruit: let fruit_pwrite_meta_stream also ftruncate empty FinderInfo
       via  248b5fc vfs_fruit: pass stream size to delete_invalid_meta_stream()
       via  1078e22 vfs_fruit: let fruit handle all aio on the FinderInfo metadata stream
       via  8c8d2d0 vfs_fruit: do ino calculation
       via  a9b6f3a vfs_fruit: prepare fruit_pread_meta() for reading on fake-fd
       via  257281c vfs_fruit: prepare fruit_pwrite_meta() for on-demand opening and writing
       via  a3cc00f vfs_fruit: prepare struct fio for fake-fd and on-demand opening
       via  bc6d5c9 vfs_fruit: add fio->created
       via  82783db vfs_fruit: remove resource fork special casing
       via  02987f7 vfs_fruit: add some debugging of dev/ino
       via  6501f48 s4:torture/vfs/fruit: add test "empty_stream"
       via  76fb134 s4:torture/vfs/fruit: add check_stream_list_handle()
       via  e38c76e s4:torture/util: add torture_smb2_open()
       via  2807227 vfs_fruit: filter empty streams
       via  b0657fa vfs_fruit: use check on global_fruit_config.nego_aapl for macOS specific behaviour
       via  fd53ad8 s4:torture/vfs/fruit: enable AAPL extensions in a bunch of tests
       via  aa7de98 vfs_fruit: don't unlink 0-byte size truncated streams
       via  0893dd1 s4:torture/vfs/fruit: write some data to a just created teststream
       via  0cad5ea s4:torture/vfs/fruit: expand test "setinfo eof stream"
       via  347c78f vfs_fruit: update handling of read-only creation of resource fork
       via  46c5c8a s4:torture/vfs/fruit: update test "creating rsrc with read-only access" for newer macOS versions
       via  a14fe5b s4:torture/vfs/fruit: expand existing vfs_test "null afpinfo"
       via  b58b000 s4:torture/vfs/fruit: expand existing test "setinfo delete-on-close AFP_AfpInfo" a little bit
       via  758ab1e s4:torture/vfs/fruit: update test "read open rsrc after rename" to work with macOS
       via  dcd54e8 s4:torture/vfs/fruit: ensure a directory handle is closed in all code paths
       via  f2c7d60 s4:torture/vfs/fruit: update test "stream names" to work with macOS
       via  2fcc620 s4:torture/vfs/fruit: update test "SMB2/CREATE context AAPL" to work against macOS
       via  8651d0e s4:torture/vfs/fruit: set share_access to NTCREATEX_SHARE_ACCESS_MASK in check_stream_list
       via  caa5f0b s4:torture/vfs/fruit: fix a few error checks in "delete AFP_AfpInfo by writing all 0"
       via  00953bb s4:torture/vfs/fruit: skip a few tests when running against a macOS SMB server
       via  a7b85d5 vfs_streams_xattr: fix open implementation
       via  5a01f6c s4/test: fix AAPL size check
       via  45d55dc ctdb-recovery: Ban a node that causes recovery failure
       via  ce25e57 s3:smbd: remove now unused check if fsp is NULL
       via  d365e6d s3:smbd: fix SMB2 aio cancelling
       via  86a115c s4:torture/smb2/read: add test for cancelling SMB aio
       via  27fb50f vfs_delay_inject: implement pread_send and pwrite_send
       via  8ae8c56 s4:libcli/smb2: reapply request endtime
       via  d79d719 libcli: fill endtime if smbXcli_req_create() timeout is non-zero
       via  23c1e01 libcli: add smbXcli_req_endtime
      from  994c6c6 dsdb: Add comments explaining the limitations of our current backlink behaviour

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-8-test


- Log -----------------------------------------------------------------
commit b51ef80a7aa289d6b42c481640d823284b83e67d
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 1 12:09:14 2018 +0100

    torture: Fix the clang build
    
    It's used uninitialized if an early torture_assert fails
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Nov  1 17:34:31 CET 2018 on sn-devel-144
    
    (cherry picked from commit 9b28d47b0d86570be5a7c5628e460e01207afb00)
    
    Autobuild-User(v4-8-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-8-test): Tue Nov  6 13:44:37 CET 2018 on sn-devel-144

commit 0eebb6e0a47a53709b7a8ec67bd97dae7b1fd53e
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:25:26 2018 +0200

    vfs_fruit: let fruit_open_meta() with O_CREAT return a fake-fd
    
    This is the final step in implementing the needed macOS semantics on the
    FinderInfo stream: as long as the client hasn't written a non-zero
    FinderInfo blob to the stream, there mustn't be a visible filesystem
    entry for other openers.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Nov  1 01:14:23 CET 2018 on sn-devel-144
    
    (cherry picked from commit 1b2de44ea8114cf2025e8b8c843131e2f2dbed27)

commit cbbd530968bf68195450bb74339f50a0440e8dae
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 23:50:32 2018 +0200

    vfs_fruit: don't check for delete-on-close on the FinderInfo stream
    
    macOS SMB server doesn't filter out the FinderInfo stream if it has
    delete-on-close set.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit d8c1bb52018289878b9397d513ebbae63933a05f)

commit 80c95670e21f08da555f2ee1bd236a5fb8aca7ac
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 23:40:14 2018 +0200

    vfs_fruit: let fruit_pwrite_meta_stream also ftruncate empty FinderInfo
    
    fruit_streaminfo currently filters out the FinderInfo stream is
    delete-on-close is set. We set it here internally, but the client may
    also set it over SMB. Turns out that the macOS SMB server does NOT
    filter out FinderInfo stream with delete-on-close set, so we must change
    the way filtering is done in fruit_streaminfo.
    
    Filtering is now done based on the FinderInfo stream being 0-bytes large which
    is why I'm adding the ftruncate here.
    
    No idea why the tests that check the filtering passed the commits
    leading up to this one, but if you revert this commit after applying the
    whole patchset, the "delete AFP_AfpInfo by writing all 0" test will fail.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 480695cd723cc4949e0b39ddb83560efac393412)

commit 248b5fc305b3b18ff82a9567234ba46ebe779f1f
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 23:46:43 2018 +0200

    vfs_fruit: pass stream size to delete_invalid_meta_stream()
    
    delete_invalid_meta_stream() is meant to guard against random data being
    present in the FinderInfo stream. If the stream size is 0, it's likely a
    freshly created stream where no data has been written to yet, so don't
    delete it.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6e13dbddaec9f8118e11309297f85c3cdfd22e43)

commit 1078e220e5a80bc2c36eb915e5c323c286d8bc13
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 17 16:51:34 2018 +0200

    vfs_fruit: let fruit handle all aio on the FinderInfo metadata stream
    
    This will be required to support using fake fds for the FinderInfo
    metadata stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6fd256afcd5fedc894036efbfba1fc6d2264fba9)

commit 8c8d2d028dbc8957369cc4985e1b678f57c933c3
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 16:49:23 2018 +0200

    vfs_fruit: do ino calculation
    
    As we'll start returning fake fds in open shortly, we can't rely on the
    next module to calculat correct inode numbers for streams and must take
    over that responsibility.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 80afafe398566fd622f431966808d08ba9ec6473)

commit a9b6f3a03da547daee0e7d24e4f112be5b84bee0
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:22:08 2018 +0200

    vfs_fruit: prepare fruit_pread_meta() for reading on fake-fd
    
    If the read on the stream fails we may have hit a handle on a just
    created stream (fio->created=true) with no data written yet.
    
    If that's the case return an empty initialized FinderInfo blob.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit d7d92710711f6e555ed45c1dda528cd6a83e1bf5)

commit 257281c7c7f4b74e0a9d052ced1fa9d4ab74094c
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:21:08 2018 +0200

    vfs_fruit: prepare fruit_pwrite_meta() for on-demand opening and writing
    
    This avoid creating files or blobs in our streams backend when a client
    creates a stream but hasn't written anything yet. This is the only sane
    way to implement the following semantics:
    
    * client 1: create stream "file:foo"
    
    * client 2: open stream "file:foo"
    
    The second operation of client 2 must fail with NT_STATUS_NOT_FOUND.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 4a5c9a9e73230f640eb045a3c47af75b5be9f1d6)

commit a3cc00f7187a59bd2bb2c7bdd572456e70494804
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:22:57 2018 +0200

    vfs_fruit: prepare struct fio for fake-fd and on-demand opening
    
    Not used for now, that comes in the subsequent commits.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 96320eccc9a63b793ff8d05842bce54f120286f9)

commit bc6d5c9fa75ccb2368212393a9406fd4db3208e1
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 16:56:46 2018 +0200

    vfs_fruit: add fio->created
    
    fio->created tracks whether a create created a stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 1e055a79541eb69eb2deeae897dde3665c5ffee2)

commit 82783db2b10f206c9a8131466c8a98e957209f12
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 18:38:33 2018 +0200

    vfs_fruit: remove resource fork special casing
    
    Directly unlinking a file with open handles is not good, don't do it.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a26032c3f68028b01fb6a7d38851409db1858161)

commit 02987f7046944e7ce0253eb97afc8965d9177f8a
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 17 19:07:11 2018 +0200

    vfs_fruit: add some debugging of dev/ino
    
    Aids in debugging dev/ino mismatch failures in open_file_ntcreate.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 993c7c4e711612225bd07b8fa5544c4bfef88a9e)

commit 6501f483946833d4d3aebead4dba552d1829810e
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 16:21:21 2018 +0200

    s4:torture/vfs/fruit: add test "empty_stream"
    
    One to rule them all: consistently test critical operations on all
    streams relevant to macOS clients: the FinderInfo stream, the Resource
    Fork stream and an arbitrary stream that macOS maps to xattrs when
    written to on a macOS SMB server.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9d8751db64de75a0de442365b317c1b9ce194170)

commit 76fb134af8558ee6843e300c32617608a2f2dca8
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 11 17:14:50 2018 +0200

    s4:torture/vfs/fruit: add check_stream_list_handle()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit aba502d440ae3478543d3be5c5bbcea39fb0a463)

commit e38c76eed418c54e089c0442974bfbb900d0ff45
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 10 18:45:56 2018 +0200

    s4:torture/util: add torture_smb2_open()
    
    This seems to be missing: a simple wrapper to just open a file without
    fancy options.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 64b28e4a94365092f46052712a38e6fcfbb9f20c)

commit 280722734964afa847280851f6d493e2f987f060
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 14:53:50 2018 +0200

    vfs_fruit: filter empty streams
    
    First step in achieving macOS compliant behaviour wrt to empty streams:
    - hide empty streams in streaminfo
    - prevent opens of empty streams
    
    This means that we may carry 0-byte sized streams in our streams
    backend, but this shouldn't really hurt.
    
    The previous attempt of deleting the streams when an SMB setinfo eof to
    0 request came in, turned out be a road into desaster.
    
    We could set delete-on-close on the stream, but that means we'd have to
    check for it for every write on a stream and checking the
    delete-on-close bits requires fetching the locking.tdb record, so this
    is expensive and I'd like to avoid that overhead.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit ebfcf75e993b1a792db76b94aa898532e1c81eeb)

commit b0657faba457c632f111d3cb4c58d129bbf52689
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 15:28:06 2018 +0200

    vfs_fruit: use check on global_fruit_config.nego_aapl for macOS specific behaviour
    
    Ensure any non MS compliant protocol behaviour targetted at supporting
    macOS clients are only effective if the client negotiated AAPL.
    
    Currently this only guards the resource fork which only macOS client are
    going to use, but subsequent commits add more this at this place.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 046456fca60b9fef38a0cdf5a116883fb1c7dffe)

commit fd53ad87f87555d571bf75a8b3a969acf4618fe3
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 14:01:34 2018 +0200

    s4:torture/vfs/fruit: enable AAPL extensions in a bunch of tests
    
    These tests check for macOS SMB server specific behaviour. They work
    currently against Samba without enabling AAPL because in vfs_fruit we're
    currently don't check whether AAPL has been negotiated in one place. A
    subsequent commit will change that and this commit prepares for that
    change.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 7485007bb0a69dc8237c78be90f4bae06aad49b2)

commit aa7de9869be13fc28ef5112c0ab5c2951230310d
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 14:54:48 2018 +0200

    vfs_fruit: don't unlink 0-byte size truncated streams
    
    This caused all sort of havoc with subsequent SMB request that acted on
    the handle of the then deleted backend storage (file or blob, depending
    on the used streams module).
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 287082d739362ad068df37076712927ccd7ca90c)

commit 0893dd1a772e1cfa8f3da00ab2c81ec2a15b8e6e
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 14:52:23 2018 +0200

    s4:torture/vfs/fruit: write some data to a just created teststream
    
    Doesn't currently make a difference, but this prepares for a later
    change in vfs_fruit that will filter out empty streams (which is the
    macOS behaviour).
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3195ff9547824dd129e3fbcbbb8823fb10a0a5d4)

commit 0cad5ea4e913840e3b35624ccb29dacab644e23a
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 12:43:16 2018 +0200

    s4:torture/vfs/fruit: expand test "setinfo eof stream"
    
    o Adds checks verifying that after setting eof to 0 on a stream, a
      subsequent open gets ENOENT, before and after closing the handle that
      had been used to set eof to 0.
    
    o Verify that a write to a handle succeeds after that handle has been
      used to set eof to 0 on a stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b35d9e74028727da24f349242cb0bc62403a9b09)

commit 347c78f901707fca3756eafaa55ccf2648eb2137
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 12:32:09 2018 +0200

    vfs_fruit: update handling of read-only creation of resource fork
    
    macOS SMB server versions supports this since 10.12, so we adapt our
    behaviour.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 055ca448f1a2bd995291af1810c9ec94f90f32dd)

commit 46c5c8ab3797491252d96dd1722171894b7a71d5
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 15:17:08 2018 +0200

    s4:torture/vfs/fruit: update test "creating rsrc with read-only access" for newer macOS versions
    
    While this operation failed against older macOS versions, it passes
    against versions 10.12 and newer. Update the test accordingly, a
    subsequent commit will then update our implementation.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit c3cf09a0791ed4dfb7ca18d175396ac1aca5d2ed)

commit a14fe5b863b0d4c15bb30fbcc699861566e55706
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 10 12:47:07 2018 +0200

    s4:torture/vfs/fruit: expand existing vfs_test "null afpinfo"
    
    This adds a check that a read on a seperate handle also sees the
    previously created AFP_AfpInfo stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6f428607e35055b9ce1a04a625d43740bf5c76b2)

commit b58b0002802b86d8ee5e10893e8afc59c952d7b0
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 9 18:48:08 2018 +0200

    s4:torture/vfs/fruit: expand existing test "setinfo delete-on-close AFP_AfpInfo" a little bit
    
    Add a check that verifies a create on a stream gets
    NT_STATUS_DELETE_PENDING after delete-on-close has been set.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 0d9a80b6b2e3f51cad122ee0dc78c2f4dfdebcb5)

commit 758ab1e30d409298f59e3f32596e48803f429de8
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 16:24:19 2018 +0200

    s4:torture/vfs/fruit: update test "read open rsrc after rename" to work with macOS
    
    macOS SMB server seems to return NT_STATUS_SHARING_VIOLATION in this
    case while Windows 2016 returns NT_STATUS_ACCESS_DENIED.
    
    Lets stick with the Windows error code for now in the Samba fileserver,
    but let the test pass against macOS.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9cd9859dc10d425d29774d221ec9ad697192b466)

commit dcd54e8c95e5455f2d89196729c3d79a2c36a346
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 31 15:49:45 2018 +0100

    s4:torture/vfs/fruit: ensure a directory handle is closed in all code paths
    
    Otherwise we get a sharing violation when running against Samba and
    opening the directory a second time.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f7551d8fb3599a6a71dd0570bad02bdc48324107)

commit f2c7d60a64a21ff8ebd2abb0316bda48ef0a3fde
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 15:39:12 2018 +0200

    s4:torture/vfs/fruit: update test "stream names" to work with macOS
    
    o create the basefile before trying to create a stream on it, otherwise
      this fails on macOS
    
    o write something to the stream, otherwise the stream is not listed as
      macOS hides 0-byte sized streams
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 125498861abeeed5bde727ff98d88d9ce4af6c75)

commit 2fcc620a77455c413451800d33f07871956b4831
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 15:31:21 2018 +0200

    s4:torture/vfs/fruit: update test "SMB2/CREATE context AAPL" to work against macOS
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit dba9a4743fc42b57f03b6ace24753ce8091f629f)

commit 8651d0e97b483ee742f7b2c7410125b4997cd307
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 11 17:13:52 2018 +0200

    s4:torture/vfs/fruit: set share_access to NTCREATEX_SHARE_ACCESS_MASK in check_stream_list
    
    Avoid sharing conflicts with other opens on the basefile.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 1d4e50649b02c7c2314aa04e08f9946e21b6b37d)

commit caa5f0b81cf0f69a57c8a0b72e7ae8c07340f125
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 17 10:51:45 2018 +0200

    s4:torture/vfs/fruit: fix a few error checks in "delete AFP_AfpInfo by writing all 0"
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 394d1fc9ac8373ea7419ea9514750422bd6e504d)

commit 00953bbf868aee83f6e61ecb29dcf04c5c0cf65c
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 19 22:21:10 2018 +0200

    s4:torture/vfs/fruit: skip a few tests when running against a macOS SMB server
    
    These tests are designed to test specific vfs_fruit functionality.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 242f42ef79e51e35ab33331e2f2d7c9feaac36f8)

commit a7b85d5db1e7cfdb3ca935f4abb187f42fda0ddc
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Aug 23 12:07:20 2018 +0200

    vfs_streams_xattr: fix open implementation
    
    Since a long time the modules's open function happily returned success
    when opening a non existent stream without O_CREAT.
    
    This change fixes it to return -1 and errno=ENOATTR if
    
    o get_ea_value() returns NT_STATUS_NOT_FOUND (eg mapped from
      getxattr() = -1, errno=ENOATTR) and
    
    o flags doesn't contain O_CREAT
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9f58997d7a1ab0358963a45cb8bf291e7afa8068)

commit 5a01f6c746229c2005a18a4f4a9f91aebced4a2e
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Jan 11 12:25:49 2018 +0100

    s4/test: fix AAPL size check
    
    A recent commit changed the ModelString from "Samba" to "MacSamba".
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 11589a26ba40e9da90822a85b21327f49a69afda)

commit 45d55dc25b11bf83323b4465a88dc1945a232bdd
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 29 14:33:08 2018 +1100

    ctdb-recovery: Ban a node that causes recovery failure
    
    ... instead of applying banning credits.
    
    There have been a couple of cases where recovery repeatedly takes just
    over 2 minutes to fail.  Therefore, banning credits expire between
    failures and a continuously problematic node is never banned,
    resulting in endless recoveries.  This is because it takes 2
    applications of banning credits before a node is banned, which
    generally involves 2 recovery failures.
    
    The recovery helper makes up to 3 attempts to recover each database
    during a single run.  If a node causes 3 failures then this is really
    equivalent to 3 recovery failures in the model that existed before the
    recovery helper added retries.  In that case the node would have been
    banned after 2 failures.
    
    So, instead of applying banning credits to the "most failing" node,
    simply ban it directly from the recovery helper.
    
    If multiple nodes are causing recovery failures then this can cause a
    node to be banned more quickly than it might otherwise have been, even
    pre-recovery-helper.  However, 90 seconds (i.e. 3 failures) is a long
    time to be in recovery, so banning earlier seems like the best
    approach.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13670
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Mon Nov  5 06:52:33 CET 2018 on sn-devel-144
    
    (cherry picked from commit 27df4f002a594dbb2f2a38afaccf3e22f19818e1)

commit ce25e5735344cd242d822ab26aa9b241dd375362
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 31 10:21:31 2018 +0100

    s3:smbd: remove now unused check if fsp is NULL
    
    This was used internally to mark an aio request as cancelled. As the aio
    cancellation functionality has been removed, we can now also remove this
    check.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3fa45900c0ada6596daf09aa4c5054974f3394b0)

commit d365e6d9bb495773e263562e4e441a4ce8dfe852
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 19:35:59 2018 +0100

    s3:smbd: fix SMB2 aio cancelling
    
    As we currently don't attempt to cancel the internal aio request, we
    must ignore the SMB2 cancel request and continue to process the SMB2
    request, cf MS-SM2 3.3.5.16:
    
      If the target request is not successfully canceled, processing of the
      target request MUST continue and no response is sent to the cancel
      request.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 07eb805cde4db6ac74740e3cfbc56ab6f8e2118a)

commit 86a115caacd63a70bfa9480481a4770d2da20b22
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 19:29:26 2018 +0100

    s4:torture/smb2/read: add test for cancelling SMB aio
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e37ff8c5fe18d400e378bf2591e209b30473d9f9)

commit 27fb50fd22deaabc70e2951574c532fb827e3c02
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 19:28:42 2018 +0100

    vfs_delay_inject: implement pread_send and pwrite_send
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 35f9bc06722fb07143c832442d784beb204bd367)

commit 8ae8c5670017dfe7e06d13e9441ad4f9434a378c
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 02:05:45 2018 +0100

    s4:libcli/smb2: reapply request endtime
    
    tevent_req_finish() removed a possible request timeout, make sure to
    reinstall it. This happened when an interim SMB2 response was received.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit a6de555c51ca34ef24ac4b4cb672cd748d3197a1)

commit d79d7192bf27914d6d13863a2aab18beb3945bb2
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 02:04:51 2018 +0100

    libcli: fill endtime if smbXcli_req_create() timeout is non-zero
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit e7eec24d27b8694fd7626577a2aca05e99045964)

commit 23c1e018fc2e3343d7c46efae94bbe1702366d7c
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 02:03:28 2018 +0100

    libcli: add smbXcli_req_endtime
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 94ad5ee662a5bfe1c79d8a9c3fcf51d0a1d652c7)

-----------------------------------------------------------------------

Summary of changes:
 ctdb/server/ctdb_recovery_helper.c  |  46 +-
 libcli/smb/smbXcli_base.c           |  22 +-
 libcli/smb/smbXcli_base.h           |   1 +
 selftest/target/Samba3.pm           |   6 +
 source3/modules/vfs_delay_inject.c  | 262 +++++++++++
 source3/modules/vfs_fruit.c         | 501 +++++++++++---------
 source3/modules/vfs_streams_xattr.c |  64 +--
 source3/selftest/tests.py           |   2 +
 source3/smbd/aio.c                  |  28 +-
 source4/libcli/smb2/transport.c     |  17 +
 source4/selftest/tests.py           |   1 +
 source4/torture/smb2/read.c         | 116 +++++
 source4/torture/smb2/smb2.c         |   1 +
 source4/torture/smb2/util.c         |  30 ++
 source4/torture/vfs/fruit.c         | 891 ++++++++++++++++++++++++++++++++++--
 15 files changed, 1647 insertions(+), 341 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c
index 2a10b07..b02e097 100644
--- a/ctdb/server/ctdb_recovery_helper.c
+++ b/ctdb/server/ctdb_recovery_helper.c
@@ -2570,22 +2570,28 @@ static void recovery_db_recovery_done(struct tevent_req *subreq)
 
 		/* If pulling database fails multiple times */
 		if (max_credits >= NUM_RETRIES) {
-			struct ctdb_req_message message;
-
-			D_ERR("Assigning banning credits to node %u\n",
-			      max_pnn);
-
-			message.srvid = CTDB_SRVID_BANNING;
-			message.data.pnn = max_pnn;
-
-			subreq = ctdb_client_message_send(
-					state, state->ev, state->client,
-					ctdb_client_pnn(state->client),
-					&message);
+			struct ctdb_ban_state ban_state = {
+				.pnn = max_pnn,
+				.time = state->tun_list->recovery_ban_period,
+			};
+
+			D_ERR("Banning node %u for %u seconds\n",
+			      ban_state.pnn,
+			      ban_state.time);
+
+			ctdb_req_control_set_ban_state(&request,
+						       &ban_state);
+			subreq = ctdb_client_control_send(state,
+							  state->ev,
+							  state->client,
+							  ban_state.pnn,
+							  TIMEOUT(),
+							  &request);
 			if (tevent_req_nomem(subreq, req)) {
 				return;
 			}
-			tevent_req_set_callback(subreq, recovery_failed_done,
+			tevent_req_set_callback(subreq,
+						recovery_failed_done,
 						req);
 		} else {
 			tevent_req_error(req, EIO);
@@ -2608,15 +2614,25 @@ static void recovery_failed_done(struct tevent_req *subreq)
 {
 	struct tevent_req *req = tevent_req_callback_data(
 		subreq, struct tevent_req);
+	struct recovery_state *state = tevent_req_data(
+		req, struct recovery_state);
+	struct ctdb_reply_control *reply;
 	int ret;
 	bool status;
 
-	status = ctdb_client_message_recv(subreq, &ret);
+	status = ctdb_client_control_recv(subreq, &ret, state, &reply);
 	TALLOC_FREE(subreq);
 	if (! status) {
-		D_ERR("failed to assign banning credits, ret=%d\n", ret);
+		D_ERR("failed to ban node, ret=%d\n", ret);
+		goto done;
+	}
+
+	ret = ctdb_reply_control_set_ban_state(reply);
+	if (ret != 0) {
+		D_ERR("control SET_BAN_STATE failed, ret=%d\n", ret);
 	}
 
+done:
 	tevent_req_error(req, EIO);
 }
 
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index e9fdc1d..389c272 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -227,6 +227,8 @@ struct smbXcli_req_state {
 
 	struct tevent_req *write_req;
 
+	struct timeval endtime;
+
 	struct {
 		/* Space for the header including the wct */
 		uint8_t hdr[HDR_VWV];
@@ -1583,10 +1585,8 @@ struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx,
 	state->smb1.iov_count = iov_count + 4;
 
 	if (timeout_msec > 0) {
-		struct timeval endtime;
-
-		endtime = timeval_current_ofs_msec(timeout_msec);
-		if (!tevent_req_set_endtime(req, ev, endtime)) {
+		state->endtime = timeval_current_ofs_msec(timeout_msec);
+		if (!tevent_req_set_endtime(req, ev, state->endtime)) {
 			return req;
 		}
 	}
@@ -2892,6 +2892,14 @@ static void smb2cli_req_cancel_done(struct tevent_req *subreq)
 	TALLOC_FREE(subreq);
 }
 
+struct timeval smbXcli_req_endtime(struct tevent_req *req)
+{
+	struct smbXcli_req_state *state = tevent_req_data(
+		req, struct smbXcli_req_state);
+
+	return state->endtime;
+}
+
 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 				      struct tevent_context *ev,
 				      struct smbXcli_conn *conn,
@@ -3041,10 +3049,8 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 	}
 
 	if (timeout_msec > 0) {
-		struct timeval endtime;
-
-		endtime = timeval_current_ofs_msec(timeout_msec);
-		if (!tevent_req_set_endtime(req, ev, endtime)) {
+		state->endtime = timeval_current_ofs_msec(timeout_msec);
+		if (!tevent_req_set_endtime(req, ev, state->endtime)) {
 			return req;
 		}
 	}
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 20ef26e..536c7ab 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -74,6 +74,7 @@ NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
 
 void smbXcli_req_unset_pending(struct tevent_req *req);
 bool smbXcli_req_set_pending(struct tevent_req *req);
+struct timeval smbXcli_req_endtime(struct tevent_req *req);
 
 uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn);
 uint32_t smb1cli_conn_max_xmit(struct smbXcli_conn *conn);
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 173d799..968c6aa 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2225,6 +2225,12 @@ sub provision($$$$$$$$$)
 	kernel oplocks = no
 	posix locking = no
 	include = $libdir/delay_inject.conf
+
+[aio_delay_inject]
+	copy = tmp
+	vfs objects = delay_inject
+	delay_inject:pread_send = 2000
+	delay_inject:pwrite_send = 2000
 	";
 	close(CONF);
 
diff --git a/source3/modules/vfs_delay_inject.c b/source3/modules/vfs_delay_inject.c
index 21fea9b..d561fad 100644
--- a/source3/modules/vfs_delay_inject.c
+++ b/source3/modules/vfs_delay_inject.c
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "smbd/smbd.h"
+#include "lib/util/tevent_unix.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -46,8 +47,269 @@ static int vfs_delay_inject_ntimes(vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
 }
 
+struct vfs_delay_inject_pread_state {
+	struct tevent_context *ev;
+	struct vfs_handle_struct *handle;
+	struct files_struct *fsp;
+	void *data;
+	size_t n;
+	off_t offset;
+	ssize_t ret;
+	struct vfs_aio_state vfs_aio_state;
+};
+
+static void vfs_delay_inject_pread_wait_done(struct tevent_req *subreq);
+static void vfs_delay_inject_pread_done(struct tevent_req *subreq);
+
+static struct tevent_req *vfs_delay_inject_pread_send(
+				struct vfs_handle_struct *handle,
+				TALLOC_CTX *mem_ctx,
+				struct tevent_context *ev,
+				struct files_struct *fsp,
+				void *data,
+				size_t n,
+				off_t offset)
+{
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct vfs_delay_inject_pread_state *state = NULL;
+	int delay;
+	struct timeval delay_tv;
+
+	delay = lp_parm_int(
+		SNUM(handle->conn), "delay_inject", "pread_send", 0);
+	delay_tv = tevent_timeval_current_ofs(delay / 1000,
+					      (delay * 1000) % 1000000);
+
+	req = tevent_req_create(mem_ctx, &state,
+				struct vfs_delay_inject_pread_state);
+	if (req == NULL) {
+		return NULL;
+	}
+	*state = (struct vfs_delay_inject_pread_state) {
+		.ev = ev,
+		.handle = handle,
+		.fsp = fsp,
+		.data = data,
+		.n = n,
+		.offset = offset,
+	};
+
+	if (delay == 0) {
+		subreq = SMB_VFS_NEXT_PREAD_SEND(state,
+						 state->ev,
+						 state->handle,
+						 state->fsp,
+						 state->data,
+						 state->n,
+						 state->offset);
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
+		}
+		tevent_req_set_callback(subreq,
+					vfs_delay_inject_pread_done,
+					req);
+		return req;
+	}
+
+	subreq = tevent_wakeup_send(state, ev, delay_tv);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq, vfs_delay_inject_pread_wait_done, req);
+	return req;
+}
+
+
+static void vfs_delay_inject_pread_wait_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct vfs_delay_inject_pread_state *state = tevent_req_data(
+		req, struct vfs_delay_inject_pread_state);
+	bool ok;
+
+	ok = tevent_wakeup_recv(subreq);
+	TALLOC_FREE(subreq);
+	if (!ok) {
+		tevent_req_error(req, EIO);
+		return;
+	}
+
+	subreq = SMB_VFS_NEXT_PREAD_SEND(state,
+					 state->ev,
+					 state->handle,
+					 state->fsp,
+					 state->data,
+					 state->n,
+					 state->offset);
+	if (tevent_req_nomem(subreq, req)) {
+		return;
+	}
+	tevent_req_set_callback(subreq, vfs_delay_inject_pread_done, req);
+}
+
+static void vfs_delay_inject_pread_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct vfs_delay_inject_pread_state *state = tevent_req_data(
+		req, struct vfs_delay_inject_pread_state);
+
+	state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
+	TALLOC_FREE(subreq);
+
+	tevent_req_done(req);
+}
+
+static ssize_t vfs_delay_inject_pread_recv(struct tevent_req *req,
+				struct vfs_aio_state *vfs_aio_state)
+{
+	struct vfs_delay_inject_pread_state *state = tevent_req_data(
+		req, struct vfs_delay_inject_pread_state);
+
+	if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
+		return -1;
+	}
+
+	*vfs_aio_state = state->vfs_aio_state;
+	return state->ret;
+}
+
+struct vfs_delay_inject_pwrite_state {
+	struct tevent_context *ev;
+	struct vfs_handle_struct *handle;
+	struct files_struct *fsp;
+	const void *data;
+	size_t n;
+	off_t offset;
+	ssize_t ret;
+	struct vfs_aio_state vfs_aio_state;
+};
+
+static void vfs_delay_inject_pwrite_wait_done(struct tevent_req *subreq);
+static void vfs_delay_inject_pwrite_done(struct tevent_req *subreq);
+
+static struct tevent_req *vfs_delay_inject_pwrite_send(
+				struct vfs_handle_struct *handle,
+				TALLOC_CTX *mem_ctx,
+				struct tevent_context *ev,
+				struct files_struct *fsp,
+				const void *data,
+				size_t n,
+				off_t offset)
+{
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct vfs_delay_inject_pwrite_state *state = NULL;
+	int delay;
+	struct timeval delay_tv;
+
+	delay = lp_parm_int(
+		SNUM(handle->conn), "delay_inject", "pwrite_send", 0);
+	delay_tv = tevent_timeval_current_ofs(delay / 1000,
+					      (delay * 1000) % 1000000);
+
+	req = tevent_req_create(mem_ctx, &state,
+				struct vfs_delay_inject_pwrite_state);
+	if (req == NULL) {
+		return NULL;
+	}
+	*state = (struct vfs_delay_inject_pwrite_state) {
+		.ev = ev,
+		.handle = handle,
+		.fsp = fsp,
+		.data = data,
+		.n = n,
+		.offset = offset,
+	};
+
+	if (delay == 0) {
+		subreq = SMB_VFS_NEXT_PWRITE_SEND(state,
+						 state->ev,
+						 state->handle,
+						 state->fsp,
+						 state->data,
+						 state->n,
+						 state->offset);
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
+		}
+		tevent_req_set_callback(subreq,
+					vfs_delay_inject_pwrite_done,
+					req);
+		return req;
+	}
+
+	subreq = tevent_wakeup_send(state, ev, delay_tv);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(
+		subreq, vfs_delay_inject_pwrite_wait_done, req);
+	return req;
+}
+
+
+static void vfs_delay_inject_pwrite_wait_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct vfs_delay_inject_pwrite_state *state = tevent_req_data(
+		req, struct vfs_delay_inject_pwrite_state);
+	bool ok;
+
+	ok = tevent_wakeup_recv(subreq);
+	TALLOC_FREE(subreq);
+	if (!ok) {
+		tevent_req_error(req, EIO);
+		return;
+	}
+
+	subreq = SMB_VFS_NEXT_PWRITE_SEND(state,
+					 state->ev,
+					 state->handle,
+					 state->fsp,
+					 state->data,
+					 state->n,
+					 state->offset);
+	if (tevent_req_nomem(subreq, req)) {
+		return;
+	}
+	tevent_req_set_callback(subreq, vfs_delay_inject_pwrite_done, req);
+}
+
+static void vfs_delay_inject_pwrite_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct vfs_delay_inject_pwrite_state *state = tevent_req_data(
+		req, struct vfs_delay_inject_pwrite_state);
+
+	state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
+	TALLOC_FREE(subreq);
+
+	tevent_req_done(req);
+}
+
+static ssize_t vfs_delay_inject_pwrite_recv(struct tevent_req *req,
+				struct vfs_aio_state *vfs_aio_state)
+{
+	struct vfs_delay_inject_pwrite_state *state = tevent_req_data(
+		req, struct vfs_delay_inject_pwrite_state);
+
+	if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
+		return -1;
+	}
+
+	*vfs_aio_state = state->vfs_aio_state;
+	return state->ret;
+}
+
 static struct vfs_fn_pointers vfs_delay_inject_fns = {
 	.ntimes_fn = vfs_delay_inject_ntimes,
+	.pread_send_fn = vfs_delay_inject_pread_send,
+	.pread_recv_fn = vfs_delay_inject_pread_recv,
+	.pwrite_send_fn = vfs_delay_inject_pwrite_send,
+	.pwrite_recv_fn = vfs_delay_inject_pwrite_recv,
 };
 
 static_decl_vfs;
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index e8c45f1..d75ce01 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -514,6 +514,20 @@ struct fio {
 
 	/* Denote stream type, meta or rsrc */
 	adouble_type_t type;
+
+	/* Whether the create created the stream */
+	bool created;
+
+	/*
+	 * AFP_AfpInfo stream created, but not written yet, thus still a fake
+	 * pipe fd. This is set to true in fruit_open_meta if there was no
+	 * exisiting stream but the caller requested O_CREAT. It is later set to
+	 * false when we get a write on the stream that then does open and
+	 * create the stream.
+	 */
+	bool fake_fd;
+	int flags;
+	int mode;
 };
 
 /*
@@ -2374,6 +2388,10 @@ static SMB_INO_T fruit_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
 	SMB_INO_T result;
 	char *upper_sname;
 
+	DBG_DEBUG("fruit_inode called for %ju/%ju [%s]\n",
+		  (uintmax_t)sbuf->st_ex_dev,
+		  (uintmax_t)sbuf->st_ex_ino, sname);
+
 	upper_sname = talloc_strdup_upper(talloc_tos(), sname);
 	SMB_ASSERT(upper_sname != NULL);
 
@@ -2391,8 +2409,8 @@ static SMB_INO_T fruit_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
 	/* Hopefully all the variation is in the lower 4 (or 8) bytes! */
 	memcpy(&result, hash, sizeof(result));
 
-	DEBUG(10, ("fruit_inode \"%s\": ino=0x%llu\n",
-		   sname, (unsigned long long)result));
+	DBG_DEBUG("fruit_inode \"%s\": ino=%ju\n",
+		  sname, (uintmax_t)result);
 
 	return result;
 }
@@ -3385,66 +3403,68 @@ static int fruit_connect(vfs_handle_struct *handle,
 	return rc;
 }
 
+static int fruit_fake_fd(void)
+{
+	int pipe_fds[2];
+	int fd;
+	int ret;
+
+	/*
+	 * Return a valid fd, but ensure any attempt to use it returns
+	 * an error (EPIPE). Once we get a write on the handle, we open
+	 * the real fd.


-- 
Samba Shared Repository



More information about the samba-cvs mailing list