summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/gf-dirent.c39
-rw-r--r--libglusterfs/src/gf-dirent.h2
-rw-r--r--libglusterfs/src/list.h14
-rw-r--r--libglusterfs/src/syncop.c17
4 files changed, 48 insertions, 24 deletions
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c
index b5f395afc36..99c0eb6441d 100644
--- a/libglusterfs/src/gf-dirent.c
+++ b/libglusterfs/src/gf-dirent.c
@@ -171,6 +171,20 @@ gf_dirent_for_name (const char *name)
return gf_dirent;
}
+void
+gf_dirent_entry_free (gf_dirent_t *entry)
+{
+ if (!entry)
+ return;
+
+ if (entry->dict)
+ dict_unref (entry->dict);
+ if (entry->inode)
+ inode_unref (entry->inode);
+
+ list_del (&entry->list);
+ GF_FREE (entry);
+}
void
gf_dirent_free (gf_dirent_t *entries)
@@ -185,16 +199,27 @@ gf_dirent_free (gf_dirent_t *entries)
return;
list_for_each_entry_safe (entry, tmp, &entries->list, list) {
- if (entry->dict)
- dict_unref (entry->dict);
- if (entry->inode)
- inode_unref (entry->inode);
-
- list_del (&entry->list);
- GF_FREE (entry);
+ gf_dirent_entry_free (entry);
}
}
+gf_dirent_t *
+entry_copy (gf_dirent_t *source)
+{
+ gf_dirent_t *sink = NULL;
+
+ sink = gf_dirent_for_name (source->d_name);
+
+ sink->d_off = source->d_off;
+ sink->d_ino = source->d_ino;
+ sink->d_type = source->d_type;
+ sink->d_stat = source->d_stat;
+
+ if (source->inode)
+ sink->inode = inode_ref (source->inode);
+ return sink;
+}
+
void
gf_link_inode_from_dirent (xlator_t *this, inode_t *parent, gf_dirent_t *entry)
{
diff --git a/libglusterfs/src/gf-dirent.h b/libglusterfs/src/gf-dirent.h
index 07c605f82b0..faeaf411941 100644
--- a/libglusterfs/src/gf-dirent.h
+++ b/libglusterfs/src/gf-dirent.h
@@ -61,6 +61,8 @@ struct _gf_dirent_t {
#define DT_ISDIR(mode) (mode == DT_DIR)
gf_dirent_t *gf_dirent_for_name (const char *name);
+gf_dirent_t *entry_copy (gf_dirent_t *source);
+void gf_dirent_entry_free (gf_dirent_t *entry);
void gf_dirent_free (gf_dirent_t *entries);
int gf_link_inodes_from_dirent (xlator_t *this, inode_t *parent,
gf_dirent_t *entries);
diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h
index 875594136a2..b8f9a6eebd8 100644
--- a/libglusterfs/src/list.h
+++ b/libglusterfs/src/list.h
@@ -214,6 +214,20 @@ static inline void list_replace_init(struct list_head *old,
INIT_LIST_HEAD(old);
}
+/**
+ * list_rotate_left - rotate the list to the left
+ * @head: the head of the list
+ */
+static inline void list_rotate_left (struct list_head *head)
+{
+ struct list_head *first;
+
+ if (!list_empty (head)) {
+ first = head->next;
+ list_move_tail (first, head);
+ }
+}
+
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index cb08b03d44b..81eae5a9105 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -1217,23 +1217,6 @@ syncop_lookup (xlator_t *subvol, loc_t *loc, struct iatt *iatt,
return args.op_ret;
}
-static gf_dirent_t *
-entry_copy (gf_dirent_t *source)
-{
- gf_dirent_t *sink = NULL;
-
- sink = gf_dirent_for_name (source->d_name);
-
- sink->d_off = source->d_off;
- sink->d_ino = source->d_ino;
- sink->d_type = source->d_type;
- sink->d_stat = source->d_stat;
-
- if (source->inode)
- sink->inode = inode_ref (source->inode);
- return sink;
-}
-
int32_t
syncop_readdirp_cbk (call_frame_t *frame,
void *cookie,