[tarantool-patches] [PATCH v2 1/4] xlog: turn use_coio argument of xdir_collect_garbage to flags

  • From: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
  • To: kostja@xxxxxxxxxxxxx
  • Date: Tue, 23 Oct 2018 20:26:31 +0300

So that we can add more flags.
---
 src/box/memtx_engine.c |  2 +-
 src/box/vy_log.c       |  2 +-
 src/box/wal.c          |  2 +-
 src/box/xlog.c         |  4 ++--
 src/box/xlog.h         | 15 +++++++++++++--
 5 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 5a5e87e6..251989be 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -834,7 +834,7 @@ memtx_engine_collect_garbage(struct engine *engine, int64_t 
lsn)
         * That said, we have to abort garbage collection if we
         * fail to delete a snap file.
         */
-       if (xdir_collect_garbage(&memtx->snap_dir, lsn, true) != 0)
+       if (xdir_collect_garbage(&memtx->snap_dir, lsn, XDIR_GC_USE_COIO) != 0)
                return -1;
 
        return 0;
diff --git a/src/box/vy_log.c b/src/box/vy_log.c
index fc8ede59..0615dcc2 100644
--- a/src/box/vy_log.c
+++ b/src/box/vy_log.c
@@ -1078,7 +1078,7 @@ vy_log_collect_garbage(int64_t signature)
         * it is still needed for backups.
         */
        signature = vy_log_prev_checkpoint(signature);
-       xdir_collect_garbage(&vy_log.dir, signature, true);
+       xdir_collect_garbage(&vy_log.dir, signature, XDIR_GC_USE_COIO);
 }
 
 int64_t
diff --git a/src/box/wal.c b/src/box/wal.c
index 2a1353b0..f87b40ae 100644
--- a/src/box/wal.c
+++ b/src/box/wal.c
@@ -532,7 +532,7 @@ static int
 wal_collect_garbage_f(struct cbus_call_msg *data)
 {
        int64_t lsn = ((struct wal_gc_msg *)data)->lsn;
-       xdir_collect_garbage(&wal_writer_singleton.wal_dir, lsn, false);
+       xdir_collect_garbage(&wal_writer_singleton.wal_dir, lsn, 0);
        return 0;
 }
 
diff --git a/src/box/xlog.c b/src/box/xlog.c
index 90157d83..cd2d6e1d 100644
--- a/src/box/xlog.c
+++ b/src/box/xlog.c
@@ -653,7 +653,7 @@ xdir_format_filename(struct xdir *dir, int64_t signature,
 }
 
 int
-xdir_collect_garbage(struct xdir *dir, int64_t signature, bool use_coio)
+xdir_collect_garbage(struct xdir *dir, int64_t signature, unsigned flags)
 {
        struct vclock *vclock;
        while ((vclock = vclockset_first(&dir->index)) != NULL &&
@@ -661,7 +661,7 @@ xdir_collect_garbage(struct xdir *dir, int64_t signature, 
bool use_coio)
                char *filename = xdir_format_filename(dir, vclock_sum(vclock),
                                                      NONE);
                int rc;
-               if (use_coio)
+               if (flags & XDIR_GC_USE_COIO)
                        rc = coio_unlink(filename);
                else
                        rc = unlink(filename);
diff --git a/src/box/xlog.h b/src/box/xlog.h
index c2ac4774..e3c38486 100644
--- a/src/box/xlog.h
+++ b/src/box/xlog.h
@@ -179,11 +179,22 @@ xdir_format_filename(struct xdir *dir, int64_t signature,
                     enum log_suffix suffix);
 
 /**
+ * Flags passed to xdir_collect_garbage().
+ */
+enum {
+       /**
+        * Delete files in coio threads so as not to block
+        * the caller thread.
+        */
+       XDIR_GC_USE_COIO = 1 << 0,
+};
+
+/**
  * Remove files whose signature is less than specified.
- * If @use_coio is set, files are deleted by coio threads.
+ * For possible values of @flags see XDIR_GC_*.
  */
 int
-xdir_collect_garbage(struct xdir *dir, int64_t signature, bool use_coio);
+xdir_collect_garbage(struct xdir *dir, int64_t signature, unsigned flags);
 
 /**
  * Remove inprogress files in the specified directory.
-- 
2.11.0


Other related posts: