Source-Changes-HG archive

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

[src/trunk]: src Implement disk_rename()/iostat_rename() to rename a disk.



details:   https://anonhg.NetBSD.org/src/rev/fc473232c3d7
branches:  trunk
changeset: 456663:fc473232c3d7
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed May 22 08:47:02 2019 +0000

description:
Implement disk_rename()/iostat_rename() to rename a disk.

Use it from zvol_rename_minor() when renaming a ZVOL.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c |   4 +++-
 sys/kern/subr_disk.c                              |  15 +++++++++++++--
 sys/kern/subr_iostat.c                            |  16 ++++++++++++++--
 sys/sys/disk.h                                    |   3 ++-
 sys/sys/iostat.h                                  |   3 ++-
 5 files changed, 34 insertions(+), 7 deletions(-)

diffs (121 lines):

diff -r 1184eb5307ed -r fc473232c3d7 external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c Wed May 22 08:46:27 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c Wed May 22 08:47:02 2019 +0000
@@ -3270,7 +3270,9 @@
        PNBUF_PUT(nm);
 
        strlcpy(zv->zv_name, newname, sizeof(zv->zv_name));
-       /* XXX Update dk_name? */
+       mutex_enter(&zv->zv_dklock);
+       disk_rename(&zv->zv_dk, zv->zv_name);
+       mutex_exit(&zv->zv_dklock);
 }
 #endif
 
diff -r 1184eb5307ed -r fc473232c3d7 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c      Wed May 22 08:46:27 2019 +0000
+++ b/sys/kern/subr_disk.c      Wed May 22 08:47:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_disk.c,v 1.127 2019/04/04 20:19:07 christos Exp $ */
+/*     $NetBSD: subr_disk.c,v 1.128 2019/05/22 08:47:02 hannken Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.127 2019/04/04 20:19:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.128 2019/05/22 08:47:02 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -199,6 +199,17 @@
 }
 
 /*
+ * Rename a disk.
+ */
+void
+disk_rename(struct disk *diskp, const char *name)
+{
+
+       diskp->dk_name = name;
+       iostat_rename(diskp->dk_stats, diskp->dk_name);
+}
+
+/*
  * Attach a disk.
  */
 void
diff -r 1184eb5307ed -r fc473232c3d7 sys/kern/subr_iostat.c
--- a/sys/kern/subr_iostat.c    Wed May 22 08:46:27 2019 +0000
+++ b/sys/kern/subr_iostat.c    Wed May 22 08:47:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_iostat.c,v 1.24 2018/09/03 16:29:35 riastradh Exp $       */
+/*     $NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $ */
 /*     NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp     */
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.24 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.25 2019/05/22 08:47:02 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -180,6 +180,18 @@
 }
 
 /*
+ * Rename i/o stats.
+ */
+void
+iostat_rename(struct io_stats *stats, const char *name)
+{
+
+       rw_enter(&iostatlist_lock, RW_WRITER);
+       (void)strlcpy(stats->io_name, name, sizeof(stats->io_name));
+       rw_exit(&iostatlist_lock);
+}
+
+/*
  * multiply timeval by unsigned integer and add to result
  */
 static void
diff -r 1184eb5307ed -r fc473232c3d7 sys/sys/disk.h
--- a/sys/sys/disk.h    Wed May 22 08:46:27 2019 +0000
+++ b/sys/sys/disk.h    Wed May 22 08:47:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disk.h,v 1.73 2018/11/06 04:04:34 mrg Exp $    */
+/*     $NetBSD: disk.h,v 1.74 2019/05/22 08:47:02 hannken Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
@@ -527,6 +527,7 @@
 
 struct proc;
 
+void   disk_rename(struct disk *, const char *);
 void   disk_attach(struct disk *);
 int    disk_begindetach(struct disk *, int (*)(device_t), device_t, int);
 void   disk_detach(struct disk *);
diff -r 1184eb5307ed -r fc473232c3d7 sys/sys/iostat.h
--- a/sys/sys/iostat.h  Wed May 22 08:46:27 2019 +0000
+++ b/sys/sys/iostat.h  Wed May 22 08:47:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iostat.h,v 1.11 2017/03/05 23:07:12 mlelstv Exp $      */
+/*     $NetBSD: iostat.h,v 1.12 2019/05/22 08:47:02 hannken Exp $      */
 
 /*-
  * Copyright (c) 1996, 1997, 2004, 2009 The NetBSD Foundation, Inc.
@@ -121,6 +121,7 @@
 struct io_stats *iostat_find(const char *);
 struct io_stats *iostat_alloc(int32_t, void *, const char *);
 void   iostat_free(struct io_stats *);
+void   iostat_rename(struct io_stats *, const char *);
 void   iostat_seek(struct io_stats *);
 #endif
 



Home | Main Index | Thread Index | Old Index