Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys introduce DKCACHE_COMBINE() macro - it combines the flag...
details: https://anonhg.NetBSD.org/src/rev/4983d9cc8d91
branches: trunk
changeset: 352500:4983d9cc8d91
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Apr 05 18:34:56 2017 +0000
description:
introduce DKCACHE_COMBINE() macro - it combines the flags in a way that
all common flags are retained, and flags regarding write cache are preserved
if either of the devices has it; callers can thus rely on write cache not
being possible to be used when both flags are missing
use the new macro for ccd(4)
diffstat:
sys/dev/ccd.c | 6 +++---
sys/sys/dkio.h | 11 ++++++++++-
2 files changed, 13 insertions(+), 4 deletions(-)
diffs (52 lines):
diff -r 1c7a69e5f964 -r 4983d9cc8d91 sys/dev/ccd.c
--- a/sys/dev/ccd.c Wed Apr 05 10:44:35 2017 +0000
+++ b/sys/dev/ccd.c Wed Apr 05 18:34:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $ */
+/* $NetBSD: ccd.c,v 1.171 2017/04/05 18:34:56 jdolecek Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.170 2017/03/30 16:50:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.171 2017/04/05 18:34:56 jdolecek Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -1432,7 +1432,7 @@
if (i == 0)
dkcache = j;
else
- dkcache &= j;
+ dkcache = DKCACHE_COMBINE(dkcache, j);
}
*((int *)data) = dkcache;
diff -r 1c7a69e5f964 -r 4983d9cc8d91 sys/sys/dkio.h
--- a/sys/sys/dkio.h Wed Apr 05 10:44:35 2017 +0000
+++ b/sys/sys/dkio.h Wed Apr 05 18:34:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkio.h,v 1.22 2015/12/08 20:36:15 christos Exp $ */
+/* $NetBSD: dkio.h,v 1.23 2017/04/05 18:34:56 jdolecek Exp $ */
/*
* Copyright (c) 1987, 1988, 1993
@@ -86,6 +86,15 @@
#define DKCACHE_WCHANGE 0x000200 /* write enable is changeable */
#define DKCACHE_SAVE 0x010000 /* cache parameters are savable/save them */
+/*
+ * Combine disk cache flags of two drives to get common cache capabilities.
+ * All common flags are retained. Besides this, if one of the disks
+ * has a write cache enabled or changeable, propagate those flags into result,
+ * even if it's not shared, to indicate that write cache is present.
+ */
+#define DKCACHE_COMBINE(a, b) \
+ (((a) & (b)) | (((a) | (b)) & (DKCACHE_WRITE|DKCACHE_WCHANGE)))
+
/* sync disk cache */
#define DIOCCACHESYNC _IOW('d', 118, int) /* sync cache (force?) */
Home |
Main Index |
Thread Index |
Old Index