Skip to content

Commit

Permalink
dentry fop serializer: added new server side xlator for dentry fop se…
Browse files Browse the repository at this point in the history
…rialization

Problems addressed by this xlator :

[1]. To prevent race between parallel mkdir,mkdir and lookup etc.

Fops like mkdir/create, lookup, rename, unlink, link that happen on a
particular dentry must be serialized to ensure atomicity.

Another possible case can be a fresh lookup to find existance of a path
whose gfid is not set yet. Further, storage/posix employs a ctime based
heuristic 'is_fresh_file' (interval time is less than 1 second of current
time) to check fresh-ness of file. With serialization of these two fops
(lookup & mkdir), we eliminate the race altogether.

[2]. Staleness of dentries

This causes exponential increase in traversal time for any inode in the
subtree of the directory pointed by stale dentry.

Cause :  Stale dentry is created because of following two operations:

      a. dentry creation due to inode_link, done during operations like
         lookup, mkdir, create, mknod, symlink, create and
      b. dentry unlinking due to various operations like rmdir, rename,
         unlink.

       The reason is __inode_link uses __is_dentry_cyclic, which explores
       all possible path to avoid cyclic link formation during inode
       linkage. __is_dentry_cyclic explores stale-dentry(ies) and its
       all ancestors which is increases traversing time exponentially.

Implementation : To acheive this all fops on dentry must take entry locks
before they proceed, once they have acquired locks, they perform the fop
and then release the lock.

Some documentation from email conversation:
[1] http://www.gluster.org/pipermail/gluster-devel/2015-December/047314.html

[2] http://www.gluster.org/pipermail/gluster-devel/2015-August/046428.html

With this patch, the feature is optional, enable it by running:

 `gluster volume set $volname features.sdfs enable`

Also the feature is tested for a month without issues in the
experiemental branch for all the regression.

Change-Id: I6e80ba3cabfa6facd5dda63bd482b9bf18b6b79b
Fixes: #397
Signed-off-by: Sakshi Bansal <sabansal@redhat.com>
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
  • Loading branch information
Sakshi Bansal authored and ShyamsundarR committed Jan 30, 2018
1 parent 136c347 commit ea972d9
Show file tree
Hide file tree
Showing 11 changed files with 1,532 additions and 4 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -152,6 +152,8 @@ AC_CONFIG_FILES([Makefile
xlators/features/marker/src/Makefile
xlators/features/selinux/Makefile
xlators/features/selinux/src/Makefile
xlators/features/sdfs/Makefile
xlators/features/sdfs/src/Makefile
xlators/features/read-only/Makefile
xlators/features/read-only/src/Makefile
xlators/features/compress/Makefile
Expand Down
1 change: 1 addition & 0 deletions glusterfs.spec.in
Expand Up @@ -1256,6 +1256,7 @@ exit 0
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/sdfs.so
%if ( 0%{!?_without_tiering:1} )
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so
%{_libdir}/libgfdb.so.*
Expand Down
1 change: 1 addition & 0 deletions libglusterfs/src/glfs-message-id.h
Expand Up @@ -85,6 +85,7 @@ enum _msgid_comp {
GLFS_MSGID_COMP(NLC, 1),
GLFS_MSGID_COMP(SL, 1),
GLFS_MSGID_COMP(HAM, 1),
GLFS_MSGID_COMP(SDFS, 1),

/* --- new segments for messages goes above this line --- */

Expand Down
7 changes: 3 additions & 4 deletions xlators/features/Makefile.am
@@ -1,6 +1,5 @@
SUBDIRS = locks quota read-only quiesce marker index barrier \
arbiter compress changelog changetimerecorder \
gfid-access $(GLUPY_SUBDIR) upcall snapview-client snapview-server \
trash shard bit-rot leases selinux

arbiter compress changelog changetimerecorder \
gfid-access $(GLUPY_SUBDIR) upcall snapview-client snapview-server \
trash shard bit-rot leases selinux sdfs
CLEANFILES =
3 changes: 3 additions & 0 deletions xlators/features/sdfs/Makefile.am
@@ -0,0 +1,3 @@
SUBDIRS = src

CLEANFILES =
17 changes: 17 additions & 0 deletions xlators/features/sdfs/src/Makefile.am
@@ -0,0 +1,17 @@
xlator_LTLIBRARIES = sdfs.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features

sdfs_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)

sdfs_la_SOURCES = sdfs.c
sdfs_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la

noinst_HEADERS = sdfs.h sdfs-messages.h $(top_builddir)/xlators/lib/src/libxlator.h

AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
-I$(top_srcdir)/xlators/lib/src \
-I$(top_srcdir)/rpc/xdr/src/ -I$(top_builddir)/rpc/xdr/src/

AM_CFLAGS = -Wall -fno-strict-aliasing $(GF_CFLAGS)

CLEANFILES =
69 changes: 69 additions & 0 deletions xlators/features/sdfs/src/sdfs-messages.h
@@ -0,0 +1,69 @@
/*
Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
This file is licensed to you under your choice of the GNU Lesser
General Public License, version 3 or any later version (LGPLv3 or
later), or the GNU General Public License, version 2 (GPLv2), in all
cases as published by the Free Software Foundation.
*/

#ifndef _DFS_MESSAGES_H_
#define _DFS_MESSAGES_H_

#include "glfs-message-id.h"

/* file bit-rot-bitd-messages.h
* brief SDFS log-message IDs and their descriptions
*/

/* NOTE: Rules for message additions
* 1) Each instance of a message is _better_ left with a unique message ID, even
* if the message format is the same. Reasoning is that, if the message
* format needs to change in one instance, the other instances are not
* impacted or the new change does not change the ID of the instance being
* modified.
* 2) Addition of a message,
* - Should increment the GLFS_NUM_MESSAGES
* - Append to the list of messages defined, towards the end
* - Retain macro naming as glfs_msg_X (for redability across developers)
* NOTE: Rules for message format modifications
* 3) Check acorss the code if the message ID macro in question is reused
* anywhere. If reused then then the modifications should ensure correctness
* everywhere, or needs a new message ID as (1) above was not adhered to. If
* not used anywhere, proceed with the required modification.
* NOTE: Rules for message deletion
* 4) Check (3) and if used anywhere else, then cannot be deleted. If not used
* anywhere, then can be deleted, but will leave a hole by design, as
* addition rules specify modification to the end of the list and not filling
* holes.
*/

#define GLFS_SDFS_BASE GLFS_MSGID_COMP_SDFS
#define GLFS_SDFS_NUM_MESSAGES 2
#define GLFS_MSGID_END (GLFS_SDFS_BASE + \
GLFS_SDFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_x GLFS_DFS_BASE, "Invalid: Start of messages"
/*------------*/


#define SDFS_MSG_ENTRYLK_ERROR (GLFS_SDFS_BASE + 1)
/*!
* @messageid
* @diagnosis
* @recommendedaction
*
*/

#define SDFS_MSG_MKDIR_ERROR (GLFS_SDFS_BASE + 2)
/*!
* @messageid
* @diagnosis
* @recommendedaction
*
*/
/*------------*/

#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
#endif /* !_SDFS_MESSAGES_H_ */

0 comments on commit ea972d9

Please sign in to comment.