Commit Graph

87 Commits

Author SHA1 Message Date
Alan Somers
d977417d74 [skip ci] fix a typo in a comment in mdconfig.c
Sponsored by:	Axcient
Reviewed by:    mav, imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D28968
2021-03-02 18:33:45 -07:00
Bruce Evans
9e5ed8593f Use VOP_ADVISE() with POSIX_FADV_DONTNEED instead of IO_DIRECT to
implement not double-caching for reads from vnode-backed md devices.
Use VOP_ADVISE() similarly instead of !IO_DIRECT unsimilarly for writes.
Add a "cache" option to mdconfig to allow changing the default of not
caching.

This depends on a recent commit to fix VOP_ADVISE().  A previous version
had optimizations for sequential i/o's (merge the i/o's and only uncache
for discontiguous i/o's and for full blocks), but optimizations and
knowledge of block boundaries belong in VOP_ADVISE().  Read-ahead should
also be handled better, by supporting it in md and discarding it in
VOP_ADVISE().

POSIX_FADV_DONTNEED is ignored by zfs, but so is IO_DIRECT.

POSIX_FADV_DONTNEED works better than IO_DIRECT if it is not ignored,
since it only discards from the buffer cache immediately, while
IO_DIRECT also discards from the page cache immediately.

IO_DIRECT was not used for writes since it was claimed to be too slow,
but most of the slowness for writes is from doing them synchronously by
default.  Non-synchronous writes still deadlock in many cases.

IO_DIRECT only has a special implementation for ffs reads with DIRECTIO
configured.  Otherwise, if it is not ignored than it uses the buffer and
page caches normally except for discarding everything after each i/o,
and then it has much the same overheads as POSIX_FADV_DONTNEED.  The
overheads for reading with ffs and DIRECTIO were similar in tests of md.

Reviewed by:	kib
2018-12-21 08:15:31 +00:00
Bruce Evans
e6f6d8853c Fix missing (sub)options in usage message to prepare for adding a new one.
Reviewed by:	kib
2018-12-21 06:38:13 +00:00
Poul-Henning Kamp
96a3750174 Make (no)ro an alias for (no)readonly 2018-12-16 18:10:55 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Maxim Sobolev
f7ca2bbe44 Add ability to label md(4) devices.
This feature comes from the fact that we rely memory-backed md(4)
in our build process heavily. However, if the build goes haywire
the allocated resources (i.e. swap and memory-backed md(4)'s) need
to be purged. It is extremely useful to have ability to attach
arbitrary labels to each of the virtual disks so that they can
be identified and GC'ed if neecessary.

MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D10457
2017-08-28 15:54:07 +00:00
Stephen J. Kiernan
9a81ba0f24 Add MD_VERIFY option to enable O_VERIFY in open for vnode type.
Add -o [no]verify option to mdconfig (and document in man page.)
Implement GEOM attribute MNT::verified to ask md if the backing vnode is
  verified.
Check for MNT::verified in cd9660 mount to flag the mount as MNT_VERIFIED if
  the underlying device has been verified.

Reviewed by:	rwatson
Approved by:	sjg (mentor)
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D2902
2017-05-31 21:18:11 +00:00
Edward Tomasz Napierala
30545786bb Make mdconfig(8) not segfault when the kernel returns garbage data.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-02-19 16:08:58 +00:00
Stephen J. Kiernan
d2e6391342 For MD_PRELOAD type md(4) devices, if there is a file name in the preloaded
meta-data, copy it into the softc structure.

When returning md(4) device details to the caller, include the file name in
any MD_PRELOAD type devices if it is set (first character is not NUL.)

In mdconfig, for "preload" type md(4) devices, if there is file config
available, print it in the file column of the output.

Reviewed by:	brooks
Approved by:	sjg (mentor)
MFC after:	1 month
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D9529
2017-02-13 17:44:07 +00:00
Edward Tomasz Napierala
d5b0fb47eb Add 'p' postfix to mdconfig(8).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-10-10 09:37:31 +00:00
Edward Tomasz Napierala
0efd9bfd47 Add "null" backend to mdconfig(8). This does exactly what the name
suggests, and is somewhat useful for benchmarking.

MFC after:	1 month
No objections from:	kib
Sponsored by:	The FreeBSD Foundation
2013-12-04 07:38:23 +00:00
Hiroki Sato
4103b0b025 Return 0 if:
1. "-u N" specified, no -f, and mdN found,
  2. no -u, "-f /pathname" specified, and mdN associated with /pathname found,
  3. "-u N" specified, "-f /pathname" specified, and both of them found,
  4. "-l" specified and no -f,
  5. "-l" specified, "-f /pathname" specified, and /pathname found.

otherwise return -1.

Spotted by:	Julian H. Stacey
2013-10-24 01:06:44 +00:00
Xin LI
cab9f71ffe Resolve fflag with realpath().
MFC after:	2 weeks
2013-07-31 07:06:58 +00:00
Xin LI
fa3483e67c When listing with -f, skip all memory disks that are not vnode-backed.
Noticed by:	kevlo
MFC after:	3 days
2013-07-02 19:42:47 +00:00
Hiroki Sato
db3fdd7f63 - Use length of _PATH_DEV instead of a hardcoded value[*].
- Use MD_NAME for "md".

Pointed out by:	trasz [*]
MFC after:	1 week
2013-06-21 01:47:22 +00:00
Hiroki Sato
dc017e3401 eturn -1 when the specified backing store file is not found in the md
device list.

MFC after:	1 week
2013-06-20 17:01:02 +00:00
Hiroki Sato
b78ae23fdd - Add "-f file" support to listing mode (-l). When a -f option is
specified, only md(4) devices which have the specified file as backing
  store are displayed.
- Use MD_NAME instead of "md".
- Use _PATH_DEV instead of "/dev/".

MFC after:	1 week
2013-06-20 14:30:16 +00:00
Jaakko Heinonen
734e78dfcb Disallow attaching preloaded memory disks via ioctl.
- The feature is dangerous because the kernel code didn't check
  validity of the memory address provided from user space.
- It seems that mdconfig(8) never really supported attaching preloaded
  memory disks.
- Preloaded memory disks are automatically attached during md(4)
  initialization. Thus there shouldn't be much use for the feature.

PR:		kern/169683
Discussed on:	freebsd-hackers
2012-11-21 16:56:47 +00:00
Edward Tomasz Napierala
dc604f0cf6 Make it possible to resize md(4) devices.
Reviewed by:	kib
Sponsored by:	FreeBSD Foundation
2012-07-07 20:32:21 +00:00
Edward Tomasz Napierala
cff3dc0871 Add missing "static". 2012-03-14 10:10:15 +00:00
Edward Tomasz Napierala
77c437734c Rewrite option parsing in mdconfig(8). This makes it more user-friendly
by removing the ordering requirements and adding more descriptive error
messages; it also makes it more readable and maintainable.

Sponsored by:	The FreeBSD Foundation
2012-01-27 11:48:44 +00:00
Edward Tomasz Napierala
89ef44efa3 Replace the beerware license on mdconfig(8) with standard 2-clause BSD.
Approved by:	phk@
2012-01-21 11:48:48 +00:00
Dag-Erling Smørgrav
6c49c6cff2 Somewhere around the 473rd time I mistyped "mdconfig file" instead of
"mdconfig -f file", I decided that it would be easier to make mdconfig
DWIM than to teach my fingers to type the correct command line.

MFC after:	3 weeks
2011-04-29 22:40:11 +00:00
Dag-Erling Smørgrav
3b39802214 whitespace nit - sorry for the churn 2011-04-27 21:40:49 +00:00
Dag-Erling Smørgrav
e81d0f5a74 whitespace nit 2011-04-27 21:39:59 +00:00
Rebecca Cran
c3e257a9e7 Add a check to make sure the provider name is "mdN" before printing the
unit number.

Suggested by: 	jh
MFC after:	3 days
2011-02-14 09:58:47 +00:00
Rebecca Cran
6992d350af Only print the unit number when invoked with the -n flag.
PR:	bin/144300
Submitted by:	arundel
MFC after:	3 days
2011-02-13 18:30:17 +00:00
Joel Dahl
db28020476 Use "cylinder" instead of "cyl" for consistency.
Reviewed by:	phk
2010-11-13 15:28:44 +00:00
Jaakko Heinonen
a4ca6a4926 Make mdconfig(8) WARNS=6 clean:
- Constify geom_config_get() name argument.
- Add void keyword for usage().
- Initialize mdunit to NULL.
- Don't call md_prthumanval() at all if length is NULL.

Approved by:	trasz (mentor)
2010-01-22 08:51:58 +00:00
Jaakko Heinonen
0e3ebc63e6 Print sizes up to INT64_MAX in md_prthumanval().
PR:		bin/125365
Approved by:	trasz (mentor)
MFC after:	2 weeks
2010-01-18 14:07:41 +00:00
Edward Tomasz Napierala
a9ebb31183 Add the possibility to specify "-o force" with "mdconfig -du".
Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
2009-01-10 17:17:18 +00:00
Dmitry Morozovsky
c94b8307db Add -v (verbose) option to -l command, to show size and backing store
of all md devices at one time.

Approved by:	phk
MFC after:	2 weeks
2008-06-21 15:04:42 +00:00
Florent Thoumie
69fcb5379c Fix exit code when using -l on a non-existent md(4) device.
PR:		conf/116177
Submitted by:	Remi Guyomarch <rguyom@pobox.com>
MFC after:	3 days
2007-11-16 17:40:24 +00:00
Nick Hibma
7090e3d10c Kris suggested that swap is a better choice as a default than malloc.
MFC:	1 week
2007-02-20 22:04:23 +00:00
Nick Hibma
35ce0ff2f2 [Found the original diff I made, see previous commit for other part]
Assume '-a' and '-t malloc' flags for '-s <size>' (malloc ramdisk) if not
specified.

Reviewed by:	phk (some time ago)
MFC:		1 week
2007-02-20 21:29:30 +00:00
Nick Hibma
1253fe1ead Make attach the default for -f. That way
mdconfig -f image

works like a charm.

Reviewed by:	phk (some time ago)
MFC:		1 week
2007-02-20 21:04:12 +00:00
Jason Evans
c3345c667e Unbreak the build. 2006-03-27 05:33:35 +00:00
Wojciech A. Koszek
ea3d97ae67 For now, bring back some of the old bits as a fix for specifying md(4)
device number at creation time with -u option. Together with XMLizing
mdconfig(8), I broke this functionality.

This change is temporary. Complete fix will be commited soon.

Approved by:	cognet (mentor)
2006-03-27 00:46:22 +00:00
Wojciech A. Koszek
c27a895433 Teach md(4) and mdconfig(8) how to understand XML. Right now there won't be
a problem with listing large number of md(4) devices. Either 'list' or
'query' mode uses XML.

Additionally, new functionality was introduced. It's possible to pass
multiple devices to -u:

	# ./mdconfig -l -u md0,md1

Approved by:	cognet (mentor)
2006-03-26 23:21:11 +00:00
Wojciech A. Koszek
4bfd989f3e Keep proper order of includes. Additionally, sort them. Make functions used
in that file static.

Approved by:	cognet (mentor)
2006-03-26 22:52:36 +00:00
Pawel Jakub Dawidek
a921cb3130 Use kld(3) for loading geom_md.ko. 2006-02-18 11:40:24 +00:00
Dima Dorfman
7e06d7bcbc Sort the list results by the unit number. The list returned by the
kernel is in the order the devices were made, which is not useful to
the user. Also, remove the "%d more" test since the kernel does not
return the complete count in md_pad[0] (maybe it should?).

Submitted by:	Wojciech A. Koszek
2005-12-22 10:32:11 +00:00
Pawel Jakub Dawidek
d941425873 Rename GEOM class kernel module g_md.ko to geom_md.ko for consistency
with the rest.

mdconfig.c:	Simplify mdmaybeload() function.
mdioctl.h:	Removed (now unused) #define.
loader.conf:	Sort GEOM classes properly.

OK'ed by:	phk
2005-11-11 11:31:23 +00:00
Christian S.J. Peron
c313f09bfb When using files as backing stores for devices, and the user has requested the
device be created read+write, check to see if the backing store is read only
through the use of the access(2) system call. If this check fails returning
EACCES, EPERM or EROFS then gracefully downgrade the access to read only. Also
print a warning message to stderr, informing the user that the access mode
they requested is not available.

This behavior used to be handled by md(4) but was changed in revision 1.154

Discussed with:	pjd, phk, Dario Freni <saturnero at freesbie dot org>
Reviewed by:	phk
2005-08-30 16:45:32 +00:00
Pawel Jakub Dawidek
5d19b2f993 We can specify device size in bytes. Document this in usage. 2005-03-01 14:56:49 +00:00
Michael Reifenberger
d111a5c972 Document the terabyte "-s" parameter in the usage string.
Split the usage line to not exceed 80 chars.
2005-02-21 09:09:07 +00:00
Ruslan Ermilov
8d646af581 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
Pawel Jakub Dawidek
0d79319a76 Allow to specify device size in bytes.
MFC after:	1 week
2005-01-22 20:02:01 +00:00
Pawel Jakub Dawidek
88b5b78d59 Rewrite piece of code which I committed some time ago that allows to
show file name for 'mdconfig -l -u <x>' command.
This allows to preserve API/ABI compatibility with version 0 (that's why
I changed version number back to 0) and will allow to merge this change
to RELENG_5.

MFC after:	5 days
2004-12-27 17:20:06 +00:00
Ruslan Ermilov
78bb116290 Sync usage() with manpage SYNOPSIS and code. 2004-11-13 17:08:52 +00:00