public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Martin Townsend <mtownsend1973@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: Retrieving number of free unused eraseblocks in a UBI filesystem
Date: Wed, 7 Dec 2016 14:14:47 +0100	[thread overview]
Message-ID: <20161207141447.1ef95a82@bbrezillon> (raw)
In-Reply-To: <CABatt_w8YsCXiCVHVCsr3QHydcaoZgayQ7a10akPJZjPZS_uMA@mail.gmail.com>

On Wed, 7 Dec 2016 13:07:25 +0000
Martin Townsend <mtownsend1973@gmail.com> wrote:

> On Wed, Dec 7, 2016 at 12:39 PM, Boris Brezillon
> <boris.brezillon@free-electrons.com> wrote:
> > On Wed, 7 Dec 2016 11:59:13 +0000
> > Martin Townsend <mtownsend1973@gmail.com> wrote:
> >  
> >> Hi,
> >>
> >> I'm running a 4.1 Kernel and have a UBI Filesystem with 2 volumes
> >> taking up all the NAND.
> >> ubinfo -d 0
> >> ubi0
> >> Volumes count:                           2
> >> Logical eraseblock size:                 126976 bytes, 124.0 KiB
> >> Total amount of logical eraseblocks:     4016 (509935616 bytes, 486.3 MiB)
> >> Amount of available logical eraseblocks: 0 (0 bytes)
> >> Maximum count of volumes                 128
> >> Count of bad physical eraseblocks:       56
> >> Count of reserved physical eraseblocks:  24
> >> Current maximum erase counter value:     15
> >> Minimum input/output unit size:          2048 bytes
> >> Character device major/minor:            249:0
> >> Present volumes:                         0, 1
> >>
> >> So I'm guessing that the Total amount of logical erase blocks is 0 as
> >> this is because I have 2 volumes of a fixed size that take up all the
> >> available eraseblocks of the /dev/ubi0 device.
> >>
> >> Is there a way of getting, per volume preferably, the number of
> >> eraseblocks that aren't being used? Or conversely get the number of
> >> eraseblocks that are used as I can work it out from the total amount
> >> of logical eraseblocks.  
> >
> > cat /sys/class/ubi/ubiX_Y/reserved_ebs
> >
> > where X is the UBI device id and Y is the volume id.
> >  
> 
> Thanks for the swift reply, this seems to give me the total number of
> eraseblocks:
> 
> # cat /sys/class/ubi/ubi0_1/reserved_ebs
> 3196
> 
> # ubinfo -d0 -n1
> Volume ID:   1 (on ubi0)
> Type:        dynamic
> Alignment:   1
> Size:        3196 LEBs (405815296 bytes, 387.0 MiB)
> State:       OK
> Name:        rootfs
> 
> # df -h .
> Filesystem      Size  Used Avail Use% Mounted on
> ubi0:rootfs     357M  135M  222M  38% /
> 
> What I would like to know is how many of them are being used and how
> many are not.

Well, for static volumes, you could extract this information from the
data_bytes sysfs file. It doesn't work for dynamic volumes though, but
even if you could extract this information from the number of mapped
LEBs, not sure it would have any meaning, because unmapped LEBs can
still be reserved by the upper layer, and just because you have a lot
of unmapped LEBs does not mean you can shrink the volume (which I guess
is your ultimate goal).

> 
> >>
> >> Many Thanks,
> >> Martin.
> >>
> >> ______________________________________________________
> >> Linux MTD discussion mailing list
> >> http://lists.infradead.org/mailman/listinfo/linux-mtd/  
> >  

  reply	other threads:[~2016-12-07 13:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 11:59 Retrieving number of free unused eraseblocks in a UBI filesystem Martin Townsend
2016-12-07 12:39 ` Boris Brezillon
2016-12-07 13:07   ` Martin Townsend
2016-12-07 13:14     ` Boris Brezillon [this message]
2016-12-07 13:55       ` Martin Townsend
2016-12-07 14:17         ` Boris Brezillon
2016-12-07 14:47           ` Martin Townsend
2016-12-07 15:00             ` Boris Brezillon
2016-12-07 15:33               ` Martin Townsend
2016-12-07 15:48                 ` Boris Brezillon
2016-12-07 16:56                   ` Martin Townsend

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=20161207141447.1ef95a82@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mtownsend1973@gmail.com \
    /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