linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Yan <tom.ty89@gmail.com>
To: util-linux@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, elliott@hpe.com, ahferroin7@gmail.com
Subject: bad handling of unpartitioned device in sysfs_devno_to_wholedisk() (which breaks mkfs.btrfs)
Date: Fri, 30 Oct 2015 09:43:28 +0800	[thread overview]
Message-ID: <CAGnHSEm4UND4aUuFMDesXQYiTGWFzv+tk1OEvMOj+6KRHC-MPw@mail.gmail.com> (raw)

So I noticed that SSD detection does work on unpartitioned devices in
mkfs.btrfs somehow:
https://bugzilla.kernel.org/show_bug.cgi?id=102921

Later I found out that it breaks at blkid_devno_to_wholedisk() in is_ssd():
http://git.kernel.org/cgit/linux/kernel/git/kdave/btrfs-progs.git/tree/mkfs.c?h=v4.2.3#n1103

which Elliot had shown an example with strace:
https://lists.01.org/pipermail/linux-nvdimm/2015-September/002109.html

And I think the problem occurs in the sysfs_get_devname() here:
https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/lib/sysfs.c?h=v2.27#n785

Since sysfs_get_devname() has to call sysfs_readlink() later, which
output a long full device path in /sys, I don't think we should call
it directly with the buffer "diskname", which people won't expect that
it has to be large enough to carry the path in the middle of the
process. For example in is_sdd(), a char array of size 32 is used
("wholedisk").

             reply	other threads:[~2015-10-30  1:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30  1:43 Tom Yan [this message]
2015-10-30 10:17 ` bad handling of unpartitioned device in sysfs_devno_to_wholedisk() (which breaks mkfs.btrfs) Karel Zak

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=CAGnHSEm4UND4aUuFMDesXQYiTGWFzv+tk1OEvMOj+6KRHC-MPw@mail.gmail.com \
    --to=tom.ty89@gmail.com \
    --cc=ahferroin7@gmail.com \
    --cc=elliott@hpe.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=util-linux@vger.kernel.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).