Subject: Use vn_rdwr in vnd (Re: kern/34882)
To: tech-kern <tech-kern@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 11/07/2006 14:57:06
------=_Part_6119_5034494.1162907826275
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,

vnd currently relies on the VOP_BMAP and VOP_STRATEGY operations to
access the vnode holding the disk image.  Unfortunately this means
that one cannot use vnd with files that live in file systems that do
not support these operations such as, for example, tmpfs or smbfs.

The attached patch makes vnd use the regular VOP_READ and VOP_WRITE
operations iff bmap/strategy are _not_ available (how this is
currently determined is quite ugly but keeps the changes
self-contained for now).  I know (from the comments in vnd) that this
is not optimal, but IMHO it's better to have vnd working* than to
worry about some minor issues.  (Implementing bmap/strategy for some
file systems doesn't seem trivial nor makes much sense I think.)

* Yes, using vnd with files in tmpfs is useful (as well as over
smbfs).  I can show you some use cases if you want them.

Comments please?

Thanks.

-- 
Julio M. Merino Vidal <jmmv84@gmail.com>
The Julipedia - http://julipedia.blogspot.com/

------=_Part_6119_5034494.1162907826275
Content-Type: text/plain; name=patch.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="patch.diff"

SW5kZXg6IHZuZC5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZpbGU6IC9jdnNyb290L3NyYy9zeXMvZGV2L3Zu
ZC5jLHYKcmV0cmlldmluZyByZXZpc2lvbiAxLjE1NgpkaWZmIC11IC1wIC1yMS4xNTYgdm5kLmMK
LS0tIHZuZC5jCTE3IE9jdCAyMDA2IDE4OjIxOjI5IC0wMDAwCTEuMTU2CisrKyB2bmQuYwk3IE5v
diAyMDA2IDEzOjU2OjA5IC0wMDAwCkBAIC0xMTksOSArMTE5LDEzIEBACiAgKiBCbG9jay9jaGFy
YWN0ZXIgaW50ZXJmYWNl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