Date: Thu, 25 Jun 1998 00:19:58 +1000 From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, peter@netplex.com.au Cc: chuckr@glue.umd.edu, freebsd-current@FreeBSD.ORG, phk@critter.freebsd.dk Subject: Re: Heads up: block devices to disappear! Message-ID: <199806241419.AAA19246@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> Block devices are also used for buffering. Examples: >> a) Linux fsck.ext2 does partial sector i/o's, so it does not work >> on character disk devices. It works OK on block disk devices >> despite lack of support for some special ioctls. >> b) The simple binary editor that I use reads/writes precisely the >> bytes bytes inspected/changed. This is normally the correct thing >> for a binary editor to do, but it does not work on character disk >> devices. > >Both of these should be able to be made to work for character access to >block orientated devices. specfs truncates and rounds the block accesses >for VBLK devices, I don't see why physio couldn't do something similar. Truncate/round on works for disk-like block devices. It didn't and couldn't work for tape-like devices. I don't like doing it automatically because using an unusual block size is usually an error. >Incidently, in kern_physio.c: > >struct buf * >phygetvpbuf(dev_t dev, int resid) >{ > struct bdevsw *bdsw; > int maxio; > > bdsw = cdevsw[major(dev)]->d_bdev; > if (bdsw == NULL) > return getpbuf(); > > maxio = bdsw->d_maxio; > if (resid > maxio) > resid = maxio; > > return getpbuf(); >} > >What is the point of passing in resid and calculating maxio? It's not >used... the calls to phygetvpbuf() could just as easily be calls to >getpbuf() directly.. It seems to be unfinished code. My version of it has always been: struct buf * physgetvpbuf(dev, resid) dev_t dev; int resid; { #ifdef NONSENSE struct bdevsw *bdsw; int maxio; bdsw = cdevsw[major(dev)]->d_bdev; if (bdsw == NULL) return (getpbuf()); maxio = bdsw->d_maxio; if (resid > maxio) resid = maxio; #endif return (getpbuf()); } >> c) Caching of (small) slow media, e.g.,: >> sleep 1000 </dev/fd0 # prevent last close >> tar tvvf /dev/fd0 # inspect floppy contents >> tar xvvf /dev/fd0 ... # read floppy contents from buffer cache. >> The last close prevention may be unnecessary under Linux (Linux at >> least used to not invalidate the cache until disk change), and doesn't >> actually work under FreeBSD (a comment in spec_close() says that >>... >tar should be able to lseek() in cases like this (like it does on SCO for >example) meaning this should be largely irrelevant. Not for small (< 8K) files in the tar image. Then read-ahead on the buffered should result in the entire image being read in the same time as it takes to lseek and read tar headers. >The specfs last close support is a mess. specfs itself is a hack that >exists because of the need to glue vnodes onto the devsw. If devsw >interface was replaced, driver interface could be vnode oriented. Anyway, Then last vnode dereference support would be a mess :-). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806241419.AAA19246>