Re: vnds considerd harmful.

2011-04-07 Thread Thordur Bjornsson
On Wed, Apr 06, 2011 at 04:25:15PM -0400, Jonathan Thornburg wrote:
 In http://marc.info/?l=openbsd-techm=130200205608892w=1,
 Thordur Bjornsson thib () openbsd ! org wrote:
  Now that I've disallowed swapping to vnd's the purpose
  of vnd (vs svnd) is suspect, it serves no purpose other
  then providing a different way of doing what svnd does
  (which imo, isn't even better).
  
  So, nuke vnds (keep svnds though!).
  
  This will make svndXn the same as vndXn etc. The idea is
  that in a few releases we'll simply remove the svnd0 notes.
 ^ - nodes.

With this diff svnd0 == vnd0 in your /dev.
 
 Could you clarify the semantics of the in a few releases plan?
 That is, are you proposing that the in a few releases OpenBSD will have
 (a) vnd == today's svnd,
bingo.

 (b) vnd == today's vnd,
 (c) vnd == some sort of merging of today's vnd and today's svnd, or
 (d) something else which hasn't occured to me yet
 
 I sort of think you're proposing (a), but I'm not entirely sure that I'm
 parsing your wording correctly...  [Hmm, I wonder if my failure-to-parse
 is related to a recent bout of perl hashes holding references to anonymous
 hashes holding references to anonymous lists. :) ]

So, yeah. vnd's will become today's svnd0's and the old style
bypassing of the buffer cache is gone (leaving only svnd0s).

Then in a few releases, the svnd device nodes will be removed.



Re: vnds considerd harmful.

2011-04-06 Thread Jonathan Thornburg
In http://marc.info/?l=openbsd-techm=130200205608892w=1,
Thordur Bjornsson thib () openbsd ! org wrote:
 Now that I've disallowed swapping to vnd's the purpose
 of vnd (vs svnd) is suspect, it serves no purpose other
 then providing a different way of doing what svnd does
 (which imo, isn't even better).
 
 So, nuke vnds (keep svnds though!).
 
 This will make svndXn the same as vndXn etc. The idea is
 that in a few releases we'll simply remove the svnd0 notes.
 
 comments/ok ?

Could you clarify the semantics of the in a few releases plan?
That is, are you proposing that the in a few releases OpenBSD will have
(a) vnd == today's svnd,
(b) vnd == today's vnd,
(c) vnd == some sort of merging of today's vnd and today's svnd, or
(d) something else which hasn't occured to me yet

I sort of think you're proposing (a), but I'm not entirely sure that I'm
parsing your wording correctly...  [Hmm, I wonder if my failure-to-parse
is related to a recent bout of perl hashes holding references to anonymous
hashes holding references to anonymous lists. :) ]

thanks, ciao,

-- 
-- Jonathan Thornburg [remove -animal to reply] 
jth...@astro.indiana-zebra.edu
   Dept of Astronomy  IUCSS, Indiana University, Bloomington, Indiana, USA
   Washing one's hands of the conflict between the powerful and the
powerless means to side with the powerful, not to be neutral.
  -- quote by Freire / poster by Oxfam



vnds considerd harmful.

2011-04-05 Thread Thordur Bjornsson
Hi,

Now that I've disallowed swapping to vnd's the purpose
of vnd (vs svnd) is suspect, it serves no purpose other
then providing a different way of doing what svnd does
(which imo, isn't even better).

So, nuke vnds (keep svnds though!).

This will make svndXn the same as vndXn etc. The idea is
that in a few releases we'll simply remove the svnd0 notes.

comments/ok ?


Index: dev/vnd.c
===
RCS file: /home/thib/cvs/src/sys/dev/vnd.c,v
retrieving revision 1.108
diff -u -p -r1.108 vnd.c
--- dev/vnd.c   2 Apr 2011 15:24:03 -   1.108
+++ dev/vnd.c   3 Apr 2011 18:29:52 -
@@ -33,25 +33,11 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * from: Utah $Hdr: vn.c 1.13 94/04/02$
- *
- * @(#)vn.c8.6 (Berkeley) 4/1/94
  */
 
 /*
- * Vnode disk driver.
- *
- * Block/character interface to a vnode.  Allows one to treat a file
- * as a disk (e.g. build a filesystem in it, mount it, etc.).
- *
- * NOTE 1: This uses either the VOP_BMAP/VOP_STRATEGY interface to the
- * vnode or simple VOP_READ/VOP_WRITE.  The former is suitable for swapping
- * as it doesn't distort the local buffer cache.  The latter is good for
- * building disk images as it keeps the cache consistent after the block
- * device is closed.
+ * There is a security issue involved with this driver.
  *
- * NOTE 2: There is a security issue involved with this driver.
  * Once mounted all access to the contents of the mapped file via
  * the special file is controlled by the permissions on the special
  * file, the protection of the mapped file is ignored (effectively,
@@ -102,12 +88,8 @@ int vnddebug = 0x00;
  * DISKUNIT(), but with the minor masked off.
  */
 #definevndunit(x)  DISKUNIT(makedev(major(x), minor(x)  0x7ff))
-#definevndsimple(x)(minor(x)  0x800)
-
-/* same as MAKEDISKDEV, preserving the vndsimple() property */
 #defineVNDLABELDEV(dev)\
-   makedev(major(dev), DISKMINOR(vndunit(dev), RAW_PART) | \
-   (vndsimple(dev) ? 0x800 : 0))
+   makedev(major(dev), DISKMINOR(vndunit(dev), RAW_PART))
 
 struct vndbuf {
struct buf  vb_buf;
@@ -145,7 +127,6 @@ struct vnd_softc {
 #defineVNF_LABELLING   0x0100
 #defineVNF_WLABEL  0x0200
 #defineVNF_HAVELABEL   0x0400
-#defineVNF_SIMPLE  0x1000
 #defineVNF_READONLY0x2000
 
 #defineVNDRW(v)((v)-sc_flags  VNF_READONLY ? FREAD : 
FREAD|FWRITE)
@@ -157,7 +138,6 @@ int numvnd = 0;
 void   vndattach(int);
 
 void   vndclear(struct vnd_softc *);
-void   vndstart(struct vnd_softc *, struct buf *);
 intvndsetcred(struct vnd_softc *, struct ucred *);
 void   vndiodone(struct buf *);
 void   vndshutdown(void);
@@ -232,12 +212,6 @@ vndopen(dev_t dev, int flags, int mode, 
if ((error = vndlock(sc)) != 0)
return (error);
 
-   if (!vndsimple(dev)  sc-sc_vp != NULL 
-   (sc-sc_vp-v_type != VREG || sc-sc_keyctx != NULL)) {
-   error = EINVAL;
-   goto bad;
-   }
-
if ((flags  FWRITE)  (sc-sc_flags  VNF_READONLY)) {
error = EROFS;
goto bad;
@@ -252,20 +226,11 @@ vndopen(dev_t dev, int flags, int mode, 
part = DISKPART(dev);
pmask = 1  part;
 
-   /*
-* If any partition is open, all succeeding openings must be of the
-* same type or read-only.
-*/
-   if (sc-sc_dk.dk_openmask) {
-   if (((sc-sc_flags  VNF_SIMPLE) != 0) !=
-   (vndsimple(dev) != 0)  (flags  FWRITE)) {
-   error = EBUSY;
-   goto bad;
-   }
-   } else if (vndsimple(dev))
-   sc-sc_flags |= VNF_SIMPLE;
-   else
-   sc-sc_flags = ~VNF_SIMPLE;
+   /* XXX: OK ?*/
+   if (sc-sc_dk.dk_openmask  (flags  FWRITE)) {
+   error = EBUSY;
+   goto bad;
+   }
 
/* Check that the partition exists. */
if (part != RAW_PART 
@@ -360,30 +325,13 @@ vndclose(dev_t dev, int flags, int mode,
return (0);
 }
 
-/*
- * Two methods are used, the traditional buffercache bypassing and the
- * newer, cache-coherent on unmount, one.
- *
- * Former method:
- * Break the request into bsize pieces and submit using VOP_BMAP/VOP_STRATEGY.
- * Note that this driver can only be used for swapping over NFS on the hp
- * since nfs_strategy on the vax cannot handle u-areas and page tables.
- *
- * Latter method:
- * Repack the buffer into an uio structure and use VOP_READ/VOP_WRITE to
- * access the underlying file.
- */
 void
 vndstrategy(struct buf *bp)
 {
int unit = vndunit(bp-b_dev);
struct vnd_softc *vnd = vnd_softc[unit];
-   struct vndbuf *nbp;
-   int bsize;
off_t bn;
-   caddr_t addr;
-