Yan, Zheng [Sun, 19 Jan 2014 04:13:06 +0000 (12:13 +0800)]
mds: fix scattered wrlock rejoin
If unstable scatter lock is encountered when handling weak cache
rejoin, don't remove the recovering MDS from the scatter lock's
gather list. The reason is the recovering MDS may hold rejoined
wrlock on the scatter lock. (Rejoined wrlocks were created when
handling strong cache rejoins from survivor MDS)
When composing cache rejoin ack, if the recovering MDS is in lock's
gather list, set lock state of the recovering MDS to a compatible
unstable stable.
Yan, Zheng [Sun, 19 Jan 2014 02:36:45 +0000 (10:36 +0800)]
mds: fixes for thrash fragment
This patch contains 3 changes:
- limit the number of in progress fragmenting processes.
- reduce the probability of splitting small dirfrag.
- process the merge_queue when thrash_fragments is enabled.
Yan, Zheng [Sat, 18 Jan 2014 13:34:47 +0000 (21:34 +0800)]
mds: fix 'force dirfrags' during journal replay
For rename operation, null dentry is first replayed, it detaches
the inode from the FS hierarchy. Then primary dentry is replayed,
it updates the inode and re-attaches the inode to the FS hierarchy.
We may call CInode::force_dirfrag() when updating the inode. But
CInode::force_dirfrag() doesn't work well when inode is detached
from the FS hierarchy because adjusting fragments may also adjust
subtree map. The fix is don't detach the inode when replaying the
null dentry.
Yan, Zheng [Sat, 18 Jan 2014 12:31:36 +0000 (20:31 +0800)]
mds: journal dirfragtree change
Introduce new flag DIRTYDFT to CDir and EMetaBlob::dirlump, the new
flag indicates the dirfrag is newly fragmented and the corresponding
dirfragtree change hasn't been propagate to the directory inode.
After fragmenting subtree dirfrags, make sure DIRTYDFT flag is set
on EMetaBlob::dirlump that correspond to the resulting dirfrags.
Journal replay code uses DIRTYDFT frag to decide if dirfragtree is
scattered dirty.
Yan, Zheng [Sat, 18 Jan 2014 00:27:02 +0000 (08:27 +0800)]
mds: allow fragmenting subtree dirfrags
We can't wait until object becomes auth pinnable after freezing a
dirfrag/subtree, because it can cause deadlock. Current fragmenting
dirfrag code checks if the directory inode is auth pinnable, then
calls Locker::acquire_locks(). It avoids deadlock, but also forbids
fragmenting subtree dirfrags. We can get rid of the limitation by
using 'nonlocking auth pin' mode of Locker::acquire_locks().
Yan, Zheng [Thu, 16 Jan 2014 00:15:08 +0000 (08:15 +0800)]
mds: freeze dir deadlock detection
freezing dir and freezing tree have the same deadlock cases.
This patch adds freeze dir deadlock detection, which imitates
commit ab93aa59 (mds: freeze tree deadlock detection)
Yan, Zheng [Wed, 15 Jan 2014 08:49:23 +0000 (16:49 +0800)]
mds: improve freeze tree deadlock detection
Current code uses the start time of freezing tree to detect deadlock.
It is better to check how long the auth pin count of freezing tree
stays unchanged to decide if there is potential deadlock.
Yan, Zheng [Wed, 15 Jan 2014 07:31:25 +0000 (15:31 +0800)]
mds: handle frag mismatch for cache expire
When sending MDSFragmentNotify to peers, also replicate the new
dirfrags. This guarantees peers get new replica nonces for the
new dirfrags. So it's safe to ignore mismatched/old dirfrags in
the cache expire message.
Yan, Zheng [Wed, 15 Jan 2014 04:13:52 +0000 (12:13 +0800)]
mds: fix open undef dirfrags
Undef inode may contain a undef dirfrag (*). When undef inode is
opened, we should force fragment the undef dirfrag (*). because
we may open other dirfrags later, the undef dirfrag (*) will
overlap with them.
Yan, Zheng [Wed, 15 Jan 2014 03:12:43 +0000 (11:12 +0800)]
mds: properly set COMPLETE flag when merging dirfrags
don't keep the COMPLETE flag when merging dirfrags during journal
replay, because it's inconvenience to check if the all dirfrags
under the 'basefrag' are in the cache and complete. One special case
is that newly created dirfrag get fragmented, then the fragment
operation get rolled back. The COMPLETE flag should be preserved in
this case because the dirfrag still doesn't exist on object store.
Yan, Zheng [Tue, 14 Jan 2014 02:08:40 +0000 (10:08 +0800)]
mds: fix MDCache::adjust_subtree_after_rename()
process subtree dirfrags first, then process nested dirfrags. because
the code that processes nested dirfrags treats unprocessed subtree
dirfrags as child directories' dirfrags.
Yan, Zheng [Tue, 14 Jan 2014 01:07:16 +0000 (09:07 +0800)]
mds: fix MDCache::get_force_dirfrag_bound_set()
don't force dir fragments according to the subtree bounds in resolve
message. The resolve message was not sent by the auth MDS of these
subtree bounds dirfrags.
Yan, Zheng [Mon, 13 Jan 2014 06:52:20 +0000 (14:52 +0800)]
mds: handle frag mismatch for discover
When handle discover dirfrag message, choose an approximate frag if
the requested dirfrag doesn't exist. When handling discover dirfrag
replay, wake up appropriate waiters if the reply is different from
the the requested dirfrag.
Yan, Zheng [Mon, 13 Jan 2014 03:32:38 +0000 (11:32 +0800)]
mds: use discover_path to open remote inode
MDCache::discover_ino() doesn't work well for directories that are
fragmented to several dirfrags. Because MDCache::handle_discover()
doesn't know which dirfrags the inode lives in when the sender has
outdatad frag information.
This patch replaces all use of MDCache::discover_ino() with
MDCache::discover_path().
Current discover dirfrag code only allows discover one dirfrag at
a time. This can cause deadlock if there are directories that are
fragmented to several dirfrags. For example:
mds.0 mds.1
-----------------------------------------------------------------
freeze subtree (1.*) with bound (2.1*)
discover (2.0*) ->
handle discover (2.0*), frozen tree, wait
<- export subtree (1.*) to with bound (2.1*)
discover (2.1*), wait
commit 15a5d37a (mds: fix race between scatter gather and dirfrag export)
is incomplete, it doesn't handles the race that no fragstat/neststat is
gathered. Previous commit prevents scatter gather during exporting dir,
which eliminates races of this type.
Yan, Zheng [Sun, 12 Jan 2014 10:51:18 +0000 (18:51 +0800)]
mds: acquire scatter locks when exporting dir
If auth MDS of the subtree root inode is neither the exporter MDS
nor the importer MDS and it gathers subtree root's fragstat/neststat
while the subtree is exporting. It's possible that the exporter MDS
and the importer MDS both are auth MDS of the subtree root or both
are not auth MDS of the subtree root at the time they receive the
lock messages. So the auth MDS of the subtree root inode may get no
or duplicated fragstat/neststat for the subtree root dirfrag.
The fix is, during exporting a subtree, both the exporter MDS and
the importer MDS hold locks on scatter locks of the subtree root
inode. For the importer MDS, it tries acquiring locks on the scatter
locks when handling the MExportDirPrep message. If fails to acquire
all locks, it sends a NACK to the exporter MDS. The exporter MDS
cancels the exporting when receiving the NACK.
Yan, Zheng [Sun, 12 Jan 2014 09:31:57 +0000 (17:31 +0800)]
mds: acquire locks required by exporting dir
Start internal MDS request to acquire locks required by exporting dir.
It's more reliable than using Locker::rdlock_take_set(), It also allows
acquiring locks besides rdlock.
Only use Locker::acquire_locks() to acquire locks in the first stage of
exporting dir (before freeze the subtree). After the subtree is frozen,
to minimize the time of frozen tree, still use 'try lock' to re-acquire
the locks.
Yan, Zheng [Sun, 12 Jan 2014 07:13:42 +0000 (15:13 +0800)]
mds: introduce nonlocking auth pin
Add a parameter to Locker::acquire_locks() to enabled nonblocking
auth pin. If nonblocking mode is enabled and an object that can't
be auth pinned is encountered, Locker::acquire_locks() aborts the
MDRequest instead of waiting.
The nonlocking mode is acquired by the cases that we want to acquire
locks after auth pinning a directory or freezing a dirfrag/subtree.
Yan, Zheng [Fri, 10 Jan 2014 02:58:41 +0000 (10:58 +0800)]
mds: allow acquiring wrlock and remote wrlock at the same time
Rename may move file from one dirfrag to another dirfrag of the same
directory inode. If two dirfrags belong to different auth MDS, both
MDS should hold wrlocks on filelock/nestlock of the directory inode.
If a lock is in both wrlocks list and remote_wrlocks list, current
Locker::acquire_locks() only acquires the local wrlock. The auth MDS
of the source dirfrag doesn't have the wrlock, so slave request of
the operation may modify the dirfrag after fragstat/neststat of the
dirfrag have already been gathered. It corrupts the dirstat/neststat
accounting.
Yan, Zheng [Sun, 16 Feb 2014 14:14:50 +0000 (22:14 +0800)]
ReplicatedPG: return no data if read size is trimmed to zero
OSD should return no data if the read size is trimmed to zero by the
truncate_seq/truncate_size check. We can't rely on ObjectStore::read()
to do that because it reads the entire object when the 'len' parameter
is zero.
By default, disallow adjustment of primary affinity unless the user has
opted in by adjusting their monitor config. This will avoid some user
pain because inadvertantly setting the affinity will prevent older clients
from connecting to and using the cluster.
Sage Weil [Tue, 11 Feb 2014 17:25:04 +0000 (09:25 -0800)]
osd/OSDMap: apply primary_affinity to mapping
The behavior is a bit different for replicated and indep/erasure mode.
In the first case, we are rearranging the result. In the second case,
we can just set the primary argument to the right value.
Greg Farnum [Tue, 11 Feb 2014 21:34:39 +0000 (13:34 -0800)]
OSD: create a helper for handling OSDMap subscriptions, and clean them up
We've had some trouble with not clearing out subscription requests and
overloading the monitors (though only because of other bugs). Write a
helper for handling subscription requests that we can use to centralize
safety logic. Clear out the subscription whenever we get a map that covers
it; if there are more maps available than we received, we will issue another
subscription request based on "m->newest_map" at the end of handle_osd_map().
Notice that the helper will no longer request old maps which we already have,
and that unless forced it will not dispatch multiple subscribe requests
to a single monitor.
Skipping old maps is safe:
1) we only trim old maps when the monitor tells us to,
2) we do not send messages to our peers until we have updated our maps
from the monitor.
That means only old and broken OSDs will send us messages based on maps
in our past, and we can (and should) ignore any directives from them anyway.
Ilya Dryomov [Thu, 13 Feb 2014 17:38:10 +0000 (19:38 +0200)]
osdmaptool: fix --pool option for --test-map-object mode
Commit 7f1b12f2ef97 ("osdmaptool: add --test-map-pgs mode") broke
--pool for --test-map-object mode. Fix it, and improve --pool option
handling for both modes while at it (report strict_strtol() errors,
check if specified pool exists).
Loic Dachary [Thu, 13 Feb 2014 15:20:51 +0000 (16:20 +0100)]
mon: remove format argument from osd crush dump
The --format argument of the ceph cli is used to send the desired format
argument. The format argument is always part of the command sent to the
server. Adding it to the command description in MonCommand is not
necessary.
Loic Dachary [Thu, 13 Feb 2014 14:40:30 +0000 (15:40 +0100)]
mon: do not goto reply if a ruleset exists in pending
If the crush ruleset is found in pending, do not goto reply because it
does not exist yet. Wait for the pending proposal (and the ruleset) to
be accepted and then only return that it exists.
Basic tests and a test that create the conditions where an OSDMap
is pending with a ruleset that is not yet in the OSDMap. An attempt to
create a rule by the same name will return success and not create it again.
Loic Dachary [Sun, 9 Feb 2014 17:26:57 +0000 (18:26 +0100)]
mon: minor improvement to test-helpers.sh
* kill -9 daemons to better cope with stuck daemons
* reduce paxos propose interval to speedup tests
* look for erasure code plugins from the sources directory
Loic Dachary [Sun, 9 Feb 2014 20:18:45 +0000 (21:18 +0100)]
crush: add the dump_rule(int ruleset) method
And implement dump_rules() using dump_rule(). The indentiation and
variable names are intentionaly left as is to not confuse code being
moved around and the code changes.
Loic Dachary [Wed, 12 Feb 2014 15:58:23 +0000 (16:58 +0100)]
mon: remove racy tests from osd-pool-create.sh
Use the admin socket to create the conditions by which a pool creation
is made to wait for the next paxos proposal because the required crush
ruleset is pending.
It replaces a fragile time sensitive workaround that could fail because
of race conditions. It also has the benefit of increase the speed of the
test because there is no need to wait for a long time just to accomodate
the slowest machines.
and feed it to OSDMonitor::prepare_command_impl(). The pending OSDMap won't
be proposed because it short circuit PaxosService::dispatch. It will,
however, be proposed next time PaxosService::dispatch() gets a chance.
Loic Dachary [Wed, 12 Feb 2014 17:49:50 +0000 (18:49 +0100)]
mon: add --mon-advanced-debug-mode
When this flag is true, the mon is expected to provide functionalities
that are for developer oriented debug purposes only. It is meant to
be used by the developer and not the system administrator, because it
would allow a non-developer to break things in ways that would be very
difficult to diagnose. It should probably not be documented.
Yan, Zheng [Tue, 11 Feb 2014 05:32:23 +0000 (13:32 +0800)]
mds: remove xattr when null value is given to setxattr()
setxattr() should remove xattr if parameter 'value' is NULL. To
distinguish it from the zero-length value case, introduce a new
flag CEPH_XATTR_REMOVE for the setxattr request.
Sage Weil [Tue, 11 Feb 2014 17:24:29 +0000 (09:24 -0800)]
osd/OSDMap: fix _raw_to_up_osds for EC pools
When filtering down OSDs out of the result set (i.e., raw -> up), we can
shift positions for replicated pools but need to preserve position for
EC pools.
Sage Weil [Wed, 12 Feb 2014 21:18:04 +0000 (13:18 -0800)]
mon/OSDMonitor: fix legacy tunables warning
Warn on legacy tunables, not on non-optimal tunables. Optimal is a moving
target, but it is really the legacy defaults that we want to push people
off of.
Fixes: #7399 Signed-off-by: Sage Weil <sage@inktank.com>