Commit Graph

423 Commits

Author SHA1 Message Date
Chad Austin
2dc2a16cf2 relax InodeTable locking
Summary:
This allows multiple inodes to update their metadata simultaneously
without contending on InodeTable's locks.

Reviewed By: simpkins

Differential Revision: D7885245

fbshipit-source-id: cc8ab6cd90b7424beec314a115852e08b64026ae
2018-05-18 15:21:16 -07:00
Adam Simpkins
684fa29593 update folly::Init to call folly::initLogging()
Summary:
Update the folly::Init code to define a `--logging` command line flag, and call
`folly::initLoggingOrDie()` with the value of this command line during
initialization.

This is similar to the existing code that initializes the glog library.
(Programs can use both glog and folly logging together in the same program, and
I expect that many programs will do so as parts get converted to folly::logging
and parts remain using glog.)

Reviewed By: yfeldblum

Differential Revision: D7827344

fbshipit-source-id: 8aa239fbad43bc0b551cbe40cad7b92fa97fcdde
2018-05-15 12:38:01 -07:00
Chad Austin
abe68df349 Fix replacing an empty directory with another directory
Summary:
While running the secfs filesystem validation tests against Eden, I
discovered a test that caused the eden process to abort. I bisected
and found that D7451330 regressed renaming a directory onto an empty
one. This fixes that case.

Reviewed By: simpkins

Differential Revision: D7945727

fbshipit-source-id: 592ede1b391528c02cd12b2b6ebbf3733fe8f503
2018-05-11 14:52:07 -07:00
Chad Austin
72be488e3d add convenient operator literals for the various path piece types
Summary:
I got tired of typing PathComponentPiece{"..."} in tests so here are
some operator literals.

Reviewed By: simpkins

Differential Revision: D7956732

fbshipit-source-id: 85d9f3fd725853a54da9e70fc659bd7eb9e0862c
2018-05-11 14:52:07 -07:00
Chad Austin
577f6960d7 remove legacy Overlay code
Summary: This old Overlay code is no longer necessary.

Reviewed By: simpkins

Differential Revision: D7903912

fbshipit-source-id: 4a39d6ce7d1f6f81eb13715f2d5d17b22c10d413
2018-05-09 17:06:43 -07:00
Chad Austin
fd20487c7b implement an InodeTable for storing persistent per-inode info decoupled from memory
Summary:
A persistent (but notably non-durable) mapping from inode
number to a fixed-size record stored in a memory-mapped file.  The two
primary goals here are:

1. efficiently (and lazily) reify timestamps for inodes that aren't in the overlay
2. allow the kernel's page cache to drop pages under memory pressure

Reviewed By: simpkins

Differential Revision: D6877361

fbshipit-source-id: a4366b12e21e2bf483c83069cd93ef150829b2ac
2018-05-09 16:50:53 -07:00
Chad Austin
d9a6089dd5 mark parts of EdenTimestamp noexcept
Summary:
Make it clear (especially for the upcoming InodeMetadata struct) which
operations with EdenTimestamp and InodeTimestamps will never throw.

Reviewed By: simpkins

Differential Revision: D7920219

fbshipit-source-id: 5917da51b8128455893a1480def6f2c1c8de13d4
2018-05-09 16:50:52 -07:00
Chad Austin
52776c3666 folly::Unit{} -> folly::unit
Summary:
Per yfeldblum's comment in D7886046, we can use folly::unit instead
of folly::Unit{}. We weren't using folly::unit anywhere, so this diff
replaces folly::Unit{} elsewhere in the Eden code.

Reviewed By: yfeldblum

Differential Revision: D7913462

fbshipit-source-id: fa6ab44ceb406d38713e0f4649224a74e6e51abd
2018-05-08 13:38:02 -07:00
Michael Bolin
b4f3c70c6a Distinguish between "renaming" and "replacing" a file in the journal.
Summary:
Historically, we have seen a number of messages like the following in the Eden
logs:

```
Journal for .hg/blackbox.log holds invalid Created, Created sequence
```

Apparently we were getting these invalid sequences because we were not always
recording a "rename" correctly. The "rename" constructor for a `JournalDelta`
assumed that the source path should be included in the list of "removed" files
while the destination path should be included in the list of "created" files.
However, that is not accurate if the destination path already existed before
the user ran `mv`.

Fortunately, we already check whether the destination file exists in
`TreeInode::doRename()`, so it is straightforward to determine whether the
action is a "rename" (destination does not exist) or an "replace" (destination
already exists) and then classify the destination path accordingly.

As demonstrated by the new test introduced in this commit
(`JournalUpdateTest::moveFileReplace`), in the old implementation,
a file that was removed after it was overwritten would not show up as
removed in the merged `JournalDelta`. Because Watchman relies on
`JournalDelta::merge()` via the Thrift method `getFilesChangedSince()`,
this would cause Watchman to report such a file as still existing even
though it was removed.

This definitely caused bugs in Nuclide. It is likely that other tools that rely
on Watchman in Eden (such as Buck) may have also done incorrect things
because of this bug, so this could explain past reported issues.

Reviewed By: simpkins

Differential Revision: D7888249

fbshipit-source-id: 3e57963f27c5421a6175d1a759db8d9597ed76f3
2018-05-07 14:23:13 -07:00
Adam Simpkins
f187baef89 fix bug incorrectly reporting a file as modified
Summary:
When comparing two source control blob hashes, identical hashes can be assumed
to mean that the file contents are equal.  However, differing hashes does not
necessarily mean that the file contents differ.  In particular, mercurial
hashes history metadata in addition to the file contents when computing the
blob hash.

This updates Eden to always compare the file contents when the source control
blob hashes differ, rather than assuming that the file contents are different.

Reviewed By: wez

Differential Revision: D7825900

fbshipit-source-id: e611124a66cdd5c44589f20d1d4665a603286530
2018-04-30 22:10:01 -07:00
Adam Simpkins
8e3c09a99a move folly/experimental/logging to folly/logging/
Summary:
Promote the folly logging code out of the experimental subdirectory.
We have been using this for several months in a few projects and are pretty
happy with it so far.

After moving it out of the experimental/ subdirectory I plan to update
folly::Init() to automatically support configuring it via a `--logging` command
line flag (similar to the initialization it already does today for glog).

Reviewed By: yfeldblum, chadaustin

Differential Revision: D7755455

fbshipit-source-id: 052db34c97f7516728f7cbb1a5ad959def2f6efb
2018-04-30 21:29:29 -07:00
Adam Simpkins
dea514bbef add CMake build files
Summary: Add CMakeFiles to build Eden.

Reviewed By: wez

Differential Revision: D7479587

fbshipit-source-id: 7e0b4a756005dadc3af5c13c36ce22d1dcc15071
2018-04-30 14:37:46 -07:00
Chad Austin
c22dd7924d mark a bunch of folly::Future<folly::Unit> functions with FOLLY_NODISCARD
Summary:
To avoid bugs similar to the ones fixed in D7781691, mark a bunch of
folly::Future<folly::Unit> functions with FOLLY_NODISCARD.

Reviewed By: simpkins

Differential Revision: D7782224

fbshipit-source-id: 23ba42aa63011cc33e5a6e18d5bc6d00403a78d3
2018-04-26 21:00:25 -07:00
Chad Austin
45c33d5cfd Lock down access to the .eden directory after mount startup
Summary:
Disallow any kind of mutation operation inside of the .eden directory.  We had some
code in place to prevent some of this already, but errors (including EPERM) weren't
passed out from unlink and rename out to FUSE.

Reviewed By: simpkins

Differential Revision: D7781691

fbshipit-source-id: aaecf13779eca75d6ee8765fc8bb3727ce9341de
2018-04-26 21:00:25 -07:00
Chad Austin
a9d4c071ef give InodeBase a mode_t instead of dtype_t
Summary: The InodeTable work will homogenize mode_t storage, access, and modification across file and tree inodes.  In preparation, have InodeBase keep track of the initial mode bits instead of a dtype_t.

Reviewed By: simpkins

Differential Revision: D7031924

fbshipit-source-id: f2e6e4467cecfc0ca06ad998cce0af18a99cc251
2018-04-26 16:20:05 -07:00
Chad Austin
981e03c979 clarify getParentBuggy's comment and why TreeInodeDirHandle's use is safe
Summary: Just comments.

Reviewed By: simpkins

Differential Revision: D7749564

fbshipit-source-id: 41d222c8b73970ba77592928522e9f11d508e0cf
2018-04-24 20:27:53 -07:00
Chad Austin
13dc5d1d51 minor prefactoring split out from later diffs
Summary: Also print the inode path if the assertions in EXPECT_FILE_INODE fail.

Reviewed By: simpkins

Differential Revision: D7035517

fbshipit-source-id: 6c50acb588d1c985c7e7a1586c06f04a657698f9
2018-04-24 18:53:19 -07:00
Chad Austin
0338fc77d2 make most of recursivelyRemoveOverlayData async
Summary:
Now that Eden writes tree data into the overlay even when not
materialized, checkouts can be slow as Eden actively tries to forget
allocated inode data for potentially large trees when
kPreciseInodeMemory is false.  This pushes the bulk of that garbage
collection work onto a background thread, making checkouts fast again.

Reviewed By: simpkins

Differential Revision: D7683120

fbshipit-source-id: 2a22e4612a4438b3ed2527670343c49dfcd902bc
2018-04-24 18:53:19 -07:00
Chad Austin
7335196fed helper function for updating the time fields in struct stat
Summary: This gets rid of those pesky #ifdefs in FileInode.cpp and TreeInode.cpp.

Reviewed By: wez

Differential Revision: D7735914

fbshipit-source-id: d810461984e21f72670f43ca2d1b4f5aacbf376e
2018-04-24 13:44:10 -07:00
Adam Simpkins
0195e0f6f0 ensure that the ServerState object outlives all EdenMounts
Summary:
This updates the code to store ServerState using a shared_ptr rather than
having it be an inlined member variable of EdenServer.

Previously EdenMount objects contained a raw pointer to the ServerState, with
the reasoning that the EdenServer object should outlive the EdenMount objects.
It turns out that this is not quite true in practice--EdenMount::destroy() will
normally be called before the EdenServer is destroyed, but this may not
actually destroy the EdenMount object immediately.

This fixes a race condition in the FuseTest.initMount() test that could cause
this test to occasionally fail when run on a heavily loaded system.

Reviewed By: chadaustin

Differential Revision: D7720509

fbshipit-source-id: 056ff5985587c8d8c32c11d17ba637ebd7598677
2018-04-23 13:53:48 -07:00
Chad Austin
d0256aa116 add a test that verifies unloaded, unlinked trees don't leave orphaned data in the overlay
Summary:
I was worried we might leak data in the overlay in this particular
sequence of operations, so here's a test that shows we don't.

Reviewed By: simpkins

Differential Revision: D7663419

fbshipit-source-id: b4b0d08f863fe7b23501e9e4943d18ba0b746e42
2018-04-20 18:52:17 -07:00
Chad Austin
42e2ffad76 immediately save inode numbers when allocating a TreeInode
Summary:
When we start storing permission changes and other inode
metadata keyed on inode number, we will need to remember inode numbers
before they're accessed to handle the case where the Eden process dies
before the inode is unloaded.  Otherwise, data could be left in an
inconsistent state and some writes could be missed.

This change depends on saving (and forgetting) directories being
cheap.

Reviewed By: simpkins

Differential Revision: D7598094

fbshipit-source-id: 9ab127b30a9c09ab62aa08b50c13b3eaa40be60d
2018-04-20 18:52:17 -07:00
Adam Simpkins
5fbe610f05 split the Checkout.modifyConflict test into 3 separate tests
Summary:
Split the modifyConflict() test into 3 separate test functions.  This test
runs the same checks in 54 separate variations (3 path names, 3 checkout types,
with 6 inode load options).

For each variation we set up a new test mount, creating an overlay and
LocalStore on disk.  Simply setting up and tearing down the test mounts can be
expensive if the temporary directory is served from spinning disk.  This causes
this test to occasionally time out when run on our continuous build hosts.

Splitting the test up into 3 separate test functions will effectively give it
3x longer to run, since each test function will have a separate timeout.  This
will also enable these test functions to run in parallel (although that may not
actually help with performance if they are bottlenecked on disk I/O).

Reviewed By: chadaustin

Differential Revision: D7665409

fbshipit-source-id: 4bddd68e75f38b1b6cc2d57512a5b52855f3bade
2018-04-18 14:10:03 -07:00
Chad Austin
ce0739d7f4 remove the fdatasync() from Overlay writes
Summary:
fdatasync() has a substantial cost and is unnecessary given
our durability guarantees (and the fact that most filesystems on Linux
try to avoid data loss in this common write + rename situation anyway)

Reviewed By: simpkins

Differential Revision: D7641131

fbshipit-source-id: d041e7090dc05a4d4400f86cad9501aa8a6988a9
2018-04-16 19:09:06 -07:00
Adam Simpkins
c2d233c7b8 reduce the log level for an overlay message
Summary:
Drop the log level of the "no dir data for inode" message from DBG2 to DBG3 so
we do not have it enabled by default.  (Our default log settings are
eden=DBG2.)

Reviewed By: chadaustin

Differential Revision: D7620918

fbshipit-source-id: 25cf30af08054f3ba879bd57f3841b1035e0c75e
2018-04-13 15:46:02 -07:00
Chad Austin
42808d2ced centralize overlay dir access
Summary:
I'm about to change the code paths through which directories
are saved to and loaded from persistent storage.  To help, consolidate
those operations.

Reviewed By: simpkins

Differential Revision: D7597978

fbshipit-source-id: 9cd20027746b0a372a97b7f5daf07c1b54e6b9ce
2018-04-13 10:58:39 -07:00
Chad Austin
5ed3d0ce28 storage overview doc
Summary:
Add a document that begins to sketch out the various transitions that
our inode data structures make so we can reason about their
correctness

Reviewed By: simpkins

Differential Revision: D7434693

fbshipit-source-id: 5478c108c338ccdadc22e864b077195c8be7d1b7
2018-04-10 16:04:18 -07:00
Adam Simpkins
2ea6c866da avoid unnecessarily saving overlay state on unmount
Summary:
Once a mount point has been unmounted we no longer need to care about
outstanding FUSE reference counts--we can treat them as if they are all zero.

This updates EdenMount to tell the InodeMap when the mount point is unloaded,
and changes InodeMap::unloadInode() to make use of this information when
deciding if it needs to remember the inode information.

Previously InodeMap would save information for inodes with outstanding FUSE
reference counts.  Writing all of this state to the overlay could take a
non-trivial amount of time.

Reviewed By: chadaustin

Differential Revision: D7555998

fbshipit-source-id: 0896f867ce850ab3e61c262776d536de003685ff
2018-04-10 12:56:20 -07:00
Adam Simpkins
c8921d0218 remove alternate EDEN_HAS_COMMON_STATS code paths
Summary:
Remove the EDEN_HAS_COMMON_STATS checks now that the common/stats stubs have
the required APIs needed by Eden.

Reviewed By: wez

Differential Revision: D7479593

fbshipit-source-id: cc3db50288bfea7aefd6c91391ab800628b7978f
2018-04-10 12:19:17 -07:00
Adam Simpkins
00b9a04aa1 rename InodeBase::getRefcount() to debugGetFuseRefcount()
Summary:
Rename `getRefcount()` to `debugGetFuseRefcount()` to make it clear that this
returns the FUSE reference count rather than the pointer refcount, and that
the result should not be used for anything other than debugging or diagnostic
purposes.

There is already a `getFuseRefcount()` method to check the FUSE refcount while
the inode is being unloaded.  The only time it is safe to check the FUSE
refcount for programmatic purposes, and `getFuseRefcount()` has a `DCHECK()` to
help ensure that this is the only time it is called.

(`getFuseRefcount()` also predates `getRefcount()`, which was added for the
`eden debug inode` command in D5277870.)

Reviewed By: chadaustin

Differential Revision: D7555997

fbshipit-source-id: e66f2b3d2b9eb14f8f8878d78978851929198a31
2018-04-09 14:08:13 -07:00
Adam Simpkins
645731a8a0 release the overlay lock when EdenMount::shutdown() completes
Summary:
Change EdenMount to destroy the Overlay object as soon as the `shutdown()`
operation completes.  Previously the Overlay would not get destroyed until
EdenMount::destroy() was called.

During graceful restart we transfer mount information to the new process after
`shutdown()` completes, but potentially before `destroy()` has finished.  This
previously resulted in a race condition where the new process could start
opening the overlay before the old process had released the lock.  This change
should fix that race condition.

Reviewed By: chadaustin

Differential Revision: D7543295

fbshipit-source-id: 82ae33fe6bb0aa9f0a3b010fdd1d350c63442420
2018-04-09 12:21:03 -07:00
Adam Simpkins
7c2d0b13b1 store the Overlay using unique_ptr rather than shared_ptr
Summary: Each Overlay object should be owned only by its EdenMount.

Reviewed By: chadaustin

Differential Revision: D7543294

fbshipit-source-id: 6db40fea31ce298c61d047cba9165887e32926a1
2018-04-09 12:21:03 -07:00
Adam Simpkins
2fedc3bcea update getScmStatus() to require the commit hash as an argument
Summary:
Change getScmStatus() so that callers must explicitly specify the commit to
diff against.  This should help avoid race conditions around commit or checkout
operations where the parent commit has just changed and eden returns status
information against a commit that wasn't what the client was expecting.

This should still maintain backwards compatibility with older clients that do
not send this parameter yet: we will simply receive the hash as an empty string
in this case, and we still provide the old behavior in this case.

Reviewed By: wez

Differential Revision: D7512338

fbshipit-source-id: 1fb4645dda13b9108c66c2daaa802ea3445ac5f2
2018-04-06 12:51:31 -07:00
Chad Austin
625d1868f0 delete saved, stale inode numbers from overlay during checkout
Summary:
Now that D7451330 writes saved inode numbers into the overlay, we
need to make sure they get deleted when checking out between trees.

Reviewed By: simpkins

Differential Revision: D7327942

fbshipit-source-id: 9593c7abe9d2e424b9ca1d9c5a5ab8b285867e6e
2018-04-06 11:05:53 -07:00
Chad Austin
f4a74f6309 Always remember the inode numbers of children when unloading a tree
Summary:
Always remember the inode numbers of children when unloading
a tree.  This fixes a bug where, if a tree is unloaded during a build,
child inode numbers would be regenerated, causing the same header to
be compiled once.  gcc and clang use inode numbers to decide whether
to #include a file that uses #pragma once, so they must remain
consistent while a mount is up.

This is perhaps a bit controversial because it saves _every_ tree,
unconditionally, to the overlay.  I will either stack another diff
that ensures these overlay trees are deleted when checking out to a
new tree or make that change in place here, depending on how urgently
this fix is needed.

Reviewed By: simpkins

Differential Revision: D7451330

fbshipit-source-id: 1c3bc0d55327924c88d1a559d2557cfc158991f2
2018-04-06 11:05:53 -07:00
Chad Austin
debe121eeb add a takeover test to InodeMap
Summary: Add test demonstrating inode numbers are not consistent across takeover.

Reviewed By: simpkins

Differential Revision: D7300867

fbshipit-source-id: 1e142c28ac00b569b96b5a1867bc8632771c2be9
2018-03-30 01:06:50 -07:00
Adam Simpkins
f1d758b5b5 clean up inefficiencies in Overlay code
Summary:
This cleans up the two createOverlayFile() implementations as well as
saveOverlayDir() to all use the same logic for writing out overlay files.  This
new logic is more efficient than some of the old code, as we only open the file
once.

Additionally, this also changes the Overlay code to use openat() and related
APIs when accessing files in the overlay, so that we can specify paths relative
the top-level overlay directory.  This means that all pathnames are guaranteed
to fit in a small path length known at compile time, and we can avoid ever
allocating path names on the heap.

One potential downside of using openat() is that this functionality may not be
available on Mac OS X, so we will likely still need to provide alternate
implementations that do use heap-allocated absolute paths for Mac support.

Reviewed By: chadaustin

Differential Revision: D7411499

fbshipit-source-id: dd76395130dda4c2b9403cce04f4201f6def0d10
2018-03-28 20:52:08 -07:00
Adam Simpkins
2ffefa177e make Overlay::getFilePath() private and add a test case
Summary: Add a test case to confirm the behavior of Overlay::getFilePath().

Reviewed By: chadaustin

Differential Revision: D7411498

fbshipit-source-id: f859f29e252c1c296eb236113ad2a8b0a892db37
2018-03-28 13:13:52 -07:00
Adam Simpkins
f334d7ab79 reduce code duplication in TreeInode create methods
Summary:
Most of the logic in TreeInode::create(), symlink() and mknod() was very
similar.  This adds a TreeInode::createImpl() helper method that these three
functions can share.

This also updates TreeInode::create() to throw EEXIST if the file in question
does exist, rather than using EDEN_BUG().  I believe it is possible (but
unlikely) for this to occur in practice since inode invalidation operations
triggered by a checkout are now processed asynchronously.

Reviewed By: chadaustin

Differential Revision: D7411500

fbshipit-source-id: 85d97995139eee6bff96381561fc28e76d7a2b7c
2018-03-28 13:13:52 -07:00
Adam Simpkins
96a995962f update Overlay APIs to take inode numbers instead of paths
Summary:
Update all Overlay APIs to accept InodeNumbers and compute the path to the
overlay file internally, rather than requiring the caller to pass in the path
to the file inside the overlay.

Reviewed By: chadaustin

Differential Revision: D7411497

fbshipit-source-id: d057babb0b1b8d6c3b9adf1a21b84eed363dffa1
2018-03-28 13:13:51 -07:00
Chad Austin
e56b25df9f remove loading bit from TreeInode::Entry
Summary: After the changes in D7052470 and D7346263, this bit is no longer necessary.

Reviewed By: simpkins

Differential Revision: D7401540

fbshipit-source-id: 04f3ae0376625d4e9584f31932f46774eb5caba4
2018-03-27 13:23:13 -07:00
Adam Simpkins
6b050c7be5 restructure FileInode open refcount management
Summary:
This adds a new LockedState helper class in FileInode to also keep track of
whether or not we are currently holding an refcount on the open file/blob.  The
LockedState object automatically decrements this refcount on destruction.
Alternatively, this refcount can be transferred to a new EdenFileHandle object
when unlocking the state.

Previously most of the internal FileInode code simply used EdenFileHandle
objects to manage this refcount.  However, this is prone to deadlock, since you
have to ensure that EdenFileHandle objects are never destroyed while the state
is already locked.  This new LockedState API makes it harder to have code paths
that may accidentally destroy an EdenFileHandle object while holding the state
lock.

Reviewed By: chadaustin

Differential Revision: D7407423

fbshipit-source-id: 610fcda3220a9f49b734910b7a13e8d68a81a779
2018-03-27 11:23:42 -07:00
Adam Simpkins
b324323ad4 make inode unloading methods non-const
Summary:
Update InodeMap::onInodeUnreferenced() to take a pointer to a non-const
InodeBase.  This allows the methods it calls, including
InodeBase::updateOverlayHeader() to be non-const.

Using non-const InodeBase objects seems to make sense here since the inode is
in the process of being destroyed.

In a future diff I plan to update FileInode::updateOverlayHeader() to share the
same code as normal file methods to ensure that the overlay file is open.  This
modifies the FileInode state's open refcount, so it is useful to have this
method be non-const for that purpose.

Reviewed By: chadaustin

Differential Revision: D7407424

fbshipit-source-id: 541656c7b9b283c5e5650445de5bbdbaae3fc57f
2018-03-27 11:23:42 -07:00
Adam Simpkins
086fc9ac30 send FUSE invalidation requests in a separate thread
Summary:
Update FuseChannel to send all invalidation requests in a separate thread.

This eliminates a deadlock that could previously occur during checkout
operations.  The invalidation requests would block until they could acquire the
kernel's inode lock on the inode in question.  However, the inode lock may
already be held by another thread attempting to perform an unlink() or rename()
call.  These FUSE unlink or rename operations would be blocked waiting on
Eden's mount point rename lock, which was acquired by the checkout operation.

Checkout operations now let the invalidations complete asynchronously, but we
wait for all invalidation operations to complete before indicating to our
caller that the checkout has succeeded.

Reviewed By: chadaustin, wez

Differential Revision: D7404971

fbshipit-source-id: 6fa20c00d054e210eb0258d247d083010557f210
2018-03-27 11:23:42 -07:00
Chad Austin
d217ef6d3e fix opt build
Summary:
D7363180 introduced some shadowed variables whose warnings only broke
the opt build.

Reviewed By: simpkins

Differential Revision: D7401974

fbshipit-source-id: 49c6b16489af0f6000f0714e587fa59f503272a0
2018-03-26 12:42:53 -07:00
Chad Austin
c80f10ad03 decouple whether an entry has an inode number from materialization status
Summary:
Decouple inode number assignment from materialization status.
The idea is that we will always assign entries an inode number and
track whether an entry is materialized otherwise.  This is necessary
to give consistent inode values across remounts.

Reviewed By: simpkins

Differential Revision: D7052470

fbshipit-source-id: 80d3f2a2938463198a3132182537e6223c79d509
2018-03-23 18:21:21 -07:00
Chad Austin
bf31028299 test and fix for takeover bug when trees are referenced across a takeover
Summary:
Verify Eden handles looking up an inode by number after graceful
restart and checkout.

Reviewed By: simpkins

Differential Revision: D7346263

fbshipit-source-id: 876b4837708da9ac31f72c06e7defc797fe126f3
2018-03-23 15:06:22 -07:00
Chad Austin
c176bf06fd simplify startLoadingInode
Summary: Small refactoring prior to a fix in a later diff.

Reviewed By: simpkins

Differential Revision: D7358218

fbshipit-source-id: 198160df1aa0dc65b917c5a96c2998c3675b03fe
2018-03-23 15:06:22 -07:00
Chad Austin
f80dd19454 add a graceful takeover method to TestMount
Summary: Now we can write unit tests for takeover. :)

Reviewed By: simpkins

Differential Revision: D7345419

fbshipit-source-id: 05741dab65016c59109bf190c83be2f676a6141d
2018-03-23 15:06:22 -07:00
Adam Simpkins
b1e12ca408 fix deadlocks and other synchronization issues in FileInode
Summary:
This replaces the `ensureDataLoaded()`, `materializeForWrite()`, and
`materializeAndTruncate()` methods in `FileInode` with new safer alternatives:
`runWhileDataLoaded()`, `runWhileMaterialized()`, and `truncateAndRun()`

These new methods take a function to run, and run it while holding the state
lock with the FileInode guaranteed to be in the desired state.  They also
require the caller move in the state lock as an argument, to help ensure that
the caller gets the locking behavior correct.

The old methods required that the caller not already hold the state lock while
calling them.  This pre-condition was violated in `FileInode::write()` and
possibly other places.  They also required releasing the lock between they
confirmed the file state and when the caller's function ran, requiring
additional lock and unlock operations, and also making the code harder to
reason about since other threads could change the state during the time when
the lock was released.

Reviewed By: chadaustin

Differential Revision: D7363180

fbshipit-source-id: d8e667d0bc7006c519252a8d0682af97517997eb
2018-03-23 12:36:18 -07:00