Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dm dm: Make targets' ->sync() optional



details:   https://anonhg.NetBSD.org/src/rev/05816b143845
branches:  trunk
changeset: 466211:05816b143845
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Sun Dec 15 10:12:45 2019 +0000

description:
dm: Make targets' ->sync() optional

Apparently some targets have nothing to sync, so make it optional.

diffstat:

 sys/dev/dm/device-mapper.c      |   5 +++--
 sys/dev/dm/dm.h                 |   4 ++--
 sys/dev/dm/dm_target.c          |   8 ++------
 sys/dev/dm/dm_target_error.c    |  14 ++------------
 sys/dev/dm/dm_target_snapshot.c |   5 ++---
 sys/dev/dm/dm_target_zero.c     |  14 ++------------
 6 files changed, 13 insertions(+), 37 deletions(-)

diffs (194 lines):

diff -r 59f4bb83a861 -r 05816b143845 sys/dev/dm/device-mapper.c
--- a/sys/dev/dm/device-mapper.c        Sun Dec 15 09:42:29 2019 +0000
+++ b/sys/dev/dm/device-mapper.c        Sun Dec 15 10:12:45 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: device-mapper.c,v 1.52 2019/12/15 09:22:28 tkusumi Exp $ */
+/*        $NetBSD: device-mapper.c,v 1.53 2019/12/15 10:12:45 tkusumi Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -504,7 +504,8 @@
                 * routine basically call DIOCCACHESYNC on underlying devices.
                 */
                SLIST_FOREACH(table_en, tbl, next)
-                       table_en->target->sync(table_en);
+                       if (table_en->target->sync)
+                               table_en->target->sync(table_en);
                dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
                dm_dev_unbusy(dmv);
                break;
diff -r 59f4bb83a861 -r 05816b143845 sys/dev/dm/dm.h
--- a/sys/dev/dm/dm.h   Sun Dec 15 09:42:29 2019 +0000
+++ b/sys/dev/dm/dm.h   Sun Dec 15 10:12:45 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm.h,v 1.44 2019/12/15 09:42:29 tkusumi Exp $      */
+/*        $NetBSD: dm.h,v 1.45 2019/12/15 10:12:45 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -191,11 +191,11 @@
        char *(*info)(void *);
        char *(*table)(void *);
        int (*strategy)(dm_table_entry_t *, struct buf *);
-       int (*sync)(dm_table_entry_t *);
        int (*upcall)(dm_table_entry_t *, struct buf *);
        /*
         * Optional routines.
         */
+       int (*sync)(dm_table_entry_t *);
        int (*secsize)(dm_table_entry_t *, unsigned int *);
 
        uint32_t version[3];
diff -r 59f4bb83a861 -r 05816b143845 sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c    Sun Dec 15 09:42:29 2019 +0000
+++ b/sys/dev/dm/dm_target.c    Sun Dec 15 10:12:45 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target.c,v 1.30 2019/12/15 09:42:29 tkusumi Exp $      */
+/*        $NetBSD: dm_target.c,v 1.31 2019/12/15 10:12:45 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.30 2019/12/15 09:42:29 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.31 2019/12/15 10:12:45 tkusumi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -180,10 +180,6 @@
                printf("%s missing upcall\n", dm_target->name);
                return EINVAL;
        }
-       if (dm_target->sync == NULL) {
-               printf("%s missing sync\n", dm_target->name);
-               return EINVAL;
-       }
 
        mutex_enter(&dm_target_mutex);
 
diff -r 59f4bb83a861 -r 05816b143845 sys/dev/dm/dm_target_error.c
--- a/sys/dev/dm/dm_target_error.c      Sun Dec 15 09:42:29 2019 +0000
+++ b/sys/dev/dm/dm_target_error.c      Sun Dec 15 10:12:45 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_error.c,v 1.22 2019/12/15 09:42:29 tkusumi Exp $      */
+/*        $NetBSD: dm_target_error.c,v 1.23 2019/12/15 10:12:45 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.22 2019/12/15 09:42:29 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.23 2019/12/15 10:12:45 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper error target.
@@ -45,7 +45,6 @@
 int dm_target_error_init(dm_table_entry_t*, int, char **);
 char *dm_target_error_table(void *);
 int dm_target_error_strategy(dm_table_entry_t *, struct buf *);
-int dm_target_error_sync(dm_table_entry_t *);
 int dm_target_error_deps(dm_table_entry_t *, prop_array_t);
 int dm_target_error_destroy(dm_table_entry_t *);
 int dm_target_error_upcall(dm_table_entry_t *, struct buf *);
@@ -84,7 +83,6 @@
                dmt->init = &dm_target_error_init;
                dmt->table = &dm_target_error_table;
                dmt->strategy = &dm_target_error_strategy;
-               dmt->sync = &dm_target_error_sync;
                dmt->deps = &dm_target_error_deps;
                dmt->destroy = &dm_target_error_destroy;
                dmt->upcall = &dm_target_error_upcall;
@@ -140,14 +138,6 @@
        return 0;
 }
 
-/* Sync underlying disk caches. */
-int
-dm_target_error_sync(dm_table_entry_t *table_en)
-{
-
-       return 0;
-}
-
 /* Doesn't do anything here. */
 int
 dm_target_error_destroy(dm_table_entry_t *table_en)
diff -r 59f4bb83a861 -r 05816b143845 sys/dev/dm/dm_target_snapshot.c
--- a/sys/dev/dm/dm_target_snapshot.c   Sun Dec 15 09:42:29 2019 +0000
+++ b/sys/dev/dm/dm_target_snapshot.c   Sun Dec 15 10:12:45 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_snapshot.c,v 1.33 2019/12/15 09:42:29 tkusumi Exp $      */
+/*        $NetBSD: dm_target_snapshot.c,v 1.34 2019/12/15 10:12:45 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.33 2019/12/15 09:42:29 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.34 2019/12/15 10:12:45 tkusumi Exp $");
 
 /*
  * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being
@@ -306,7 +306,6 @@
        return 0;
 }
 
-/* XXX dummy */
 int
 dm_target_snapshot_sync(dm_table_entry_t *table_en)
 {
diff -r 59f4bb83a861 -r 05816b143845 sys/dev/dm/dm_target_zero.c
--- a/sys/dev/dm/dm_target_zero.c       Sun Dec 15 09:42:29 2019 +0000
+++ b/sys/dev/dm/dm_target_zero.c       Sun Dec 15 10:12:45 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_zero.c,v 1.24 2019/12/15 09:42:29 tkusumi Exp $      */
+/*        $NetBSD: dm_target_zero.c,v 1.25 2019/12/15 10:12:45 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.24 2019/12/15 09:42:29 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.25 2019/12/15 10:12:45 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper zero target.
@@ -45,7 +45,6 @@
 int dm_target_zero_init(dm_table_entry_t *, int, char **);
 char *dm_target_zero_table(void *);
 int dm_target_zero_strategy(dm_table_entry_t *, struct buf *);
-int dm_target_zero_sync(dm_table_entry_t *);
 int dm_target_zero_destroy(dm_table_entry_t *);
 int dm_target_zero_deps(dm_table_entry_t *, prop_array_t);
 int dm_target_zero_upcall(dm_table_entry_t *, struct buf *);
@@ -84,7 +83,6 @@
                dmt->init = &dm_target_zero_init;
                dmt->table = &dm_target_zero_table;
                dmt->strategy = &dm_target_zero_strategy;
-               dmt->sync = &dm_target_zero_sync;
                dmt->deps = &dm_target_zero_deps;
                dmt->destroy = &dm_target_zero_destroy;
                dmt->upcall = &dm_target_zero_upcall;
@@ -147,14 +145,6 @@
        return 0;
 }
 
-/* Sync underlying disk caches. */
-int
-dm_target_zero_sync(dm_table_entry_t *table_en)
-{
-
-       return 0;
-}
-
 /* Does not need to do anything here. */
 int
 dm_target_zero_destroy(dm_table_entry_t *table_en)



Home | Main Index | Thread Index | Old Index