From 515074156db5492b22ee8db58e0b91caeed8f60c Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 7 Sep 2018 14:10:37 +0530 Subject: cluster/dht: Create a linkto file if required Using the dht_filter_loc_subvol_key to create files on specific subvols did not create a linkto file. This can make the file inaccessible as lookup-optimize is now enabled by default. Change-Id: I78add5a31887378a479cb9c746b91678876b0dbe fixes: bz#1626394 Signed-off-by: N Balachandran --- xlators/cluster/dht/src/dht-common.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'xlators') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 4efc2814729..129acbef0b5 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -9141,6 +9141,7 @@ dht_create (call_frame_t *frame, xlator_t *this, { int op_errno = -1; xlator_t *subvol = NULL; + xlator_t *hashed_subvol = NULL; dht_local_t *local = NULL; int i = 0; dht_conf_t *conf = NULL; @@ -9166,6 +9167,35 @@ dht_create (call_frame_t *frame, xlator_t *this, DHT_MSG_SUBVOL_INFO, "creating %s on %s (got create on %s)", local->loc.path, subvol->name, loc->path); + + /* Since lookup-optimize is enabled by default, we need + * to create the linkto file if required. + * Note this does not check for decommisioned bricks + * and min-free-disk limits as this is a debugging tool + * and not expected to be used in production. + */ + hashed_subvol = dht_subvol_get_hashed (this, &local->loc); + + if (hashed_subvol && (hashed_subvol != subvol)) { + /* Create the linkto file and then the data file */ + local->params = dict_ref (params); + local->flags = flags; + local->mode = mode; + local->umask = umask; + local->cached_subvol = subvol; + local->hashed_subvol = hashed_subvol; + + dht_linkfile_create (frame, + dht_create_linkfile_create_cbk, + this, subvol, hashed_subvol, + &local->loc); + goto done; + } + /* We either don't have a hashed subvol or the hashed subvol is + * the same as the one specified. No need to create the linkto + * file as we expect a lookup everywhere if there are problems + * with the parent layout + */ STACK_WIND_COOKIE (frame, dht_create_cbk, subvol, subvol, subvol->fops->create, &local->loc, flags, mode, umask, fd, params); -- cgit