The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Warner Losh <imp@bsdimp.com>
To: Bakul Shah <bakul@iitbombay.org>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] FreeBSD disk devices (Re: Choice of Unix for 11/03 and 11/23+ Systems
Date: Mon, 12 Oct 2020 11:54:46 -0600	[thread overview]
Message-ID: <CANCZdfpQ5wFW+G3YaA_ocJV83LqJfaLHxMZ=5F6dKRJTxUrkvQ@mail.gmail.com> (raw)
In-Reply-To: <35E93126-1C37-471B-82E6-FEA71A062307@iitbombay.org>

[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]

On Mon, Oct 12, 2020 at 11:47 AM Bakul Shah <bakul@iitbombay.org> wrote:

> On Oct 12, 2020, at 9:57 AM, Arthur Krewat <krewat@kilonet.net> wrote:
> >
> > On 10/11/2020 9:56 PM, Warner Losh wrote:
> >> unaligned I/O on the block device
> > Sorry, I have to laugh... isn't that an oxymoron? ;)
>
> Actually there are no *block* devices in FreeBSD.
> And while raw device files such as /dev/r<blkdev>
> no longer exist, it is the block devices (with
> their buffering etc.) that are gone. Only raw devices
> exist now.
>

There's still the buffer cache that does do buffering on the devices... but
it's a different kind of buffering than traditional kernels.  but you're
right, only the cdevs are plumbed down, not the bdevs.


> And FreeBSD raw disk device drivers don't allow
> unaligned I/O access. Nor should they paper over
> what is not allowed by the underlying device. Try
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
>
> unsigned char buf[1024];
>
> int main(int c, char**v) {
>         char* a = c > 1? v[1] : "1";
>         off_t off = (off_t)strtoull(a, 0, 0);
>         ssize_t r = pread(0, buf, sizeof buf, off);
>         if (r < 0) { perror("read"); return 1; }
>         for (int i = 0; i < 4; i++) printf(" %02x", buf[i]);
>         printf("\n");
>         return 0;
> }
>

I meant something different about 'unaligned' access. I mean that the
buffers you read the data into needn't be page aligned. That causes a fair
amount of hair in the lower layers where I spend much of my time...

You are correct you have to read them on an LBA boundary.

Warner

[-- Attachment #2: Type: text/html, Size: 2440 bytes --]

  reply	other threads:[~2020-10-12 17:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-10 23:29 [TUHS] Fwd: " Noel Chiappa
2020-10-11  2:30 ` Jay Logue
2020-10-11 23:24 ` Paul Riley
2020-10-12  0:53   ` Dave Horsfall
2020-10-12  1:56     ` Warner Losh
2020-10-12  2:09       ` Andrew Warkentin
2020-10-12 16:57       ` Arthur Krewat
2020-10-12 17:46         ` [TUHS] FreeBSD disk devices (Re: " Bakul Shah
2020-10-12 17:54           ` Warner Losh [this message]
2020-10-18 20:42     ` [TUHS] Fwd: " Michael Huff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANCZdfpQ5wFW+G3YaA_ocJV83LqJfaLHxMZ=5F6dKRJTxUrkvQ@mail.gmail.com' \
    --to=imp@bsdimp.com \
    --cc=bakul@iitbombay.org \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).