All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Николай Исаев" <stvdedal@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: Freeing space on JFFS2 after removing file
Date: Wed, 14 Oct 2015 08:35:20 +0300	[thread overview]
Message-ID: <CAAAVVLTY2UnU0ps6MZr2jL9MUXLDP2tGSr5gp2fJ7kzkhfuCUg@mail.gmail.com> (raw)

Hello!

We have JFFS2 partition with files: X1, X2, X3, ...., Xn. All those
files have the same size and content.
When we tried to create new file, the error ENOSPC has occurred, which
means that the file system is full and all space is used.
With this file system state, we delete a single file (X1, for example)
in order to free space that the file used.
After that, we try to recreate the same file (X1), but the error
ENOSPC occurs again.
So, even after deleting a file, the file system does not free space to
store the same file.
The same behaviour occurs when we remount file system in order to
garbage collector does his job.

Questions:
1. Is it a JFFS2 bug?
2. Is it possible to determine when removing and subsequent creation
of a file will be successful?
3. How can we determine that the free space, shown by JFFS2, fits with
real free space on the system?

The bash script shows that:

-------------------- cut here -------------------------------------
mkdir /tmp/jffstest
cd /tmp/jffstest

#
# create empty directory and
# mount point directory
#
mkdir mnt emptydir

#
# create jffs2 image
# eraseblock size = 128 Kb
# total size      = 20 Mb
#
mkfs.jffs2 -r emptydir -o image.jffs2 --pad=20971520 -e 128

#
# mount image file
#
modprobe mtdram total_size=20480 erase_size=128
modprobe mtdblock
dd if=image.jffs2 of=/dev/mtdblock0
mount -t jffs2 /dev/mtdblock0 mnt

#
# create 15Mb and 512Kb files
# with random data
#
head -c 15m /dev/urandom >big
head -c 512k /dev/urandom >small

#
# Fill the jffs2 partition
#  firstly add big file
#  then add small files until ENOSPC occurred
#
cp big mnt/.
N=1; while cp small mnt/small_$N; do N=$(( N + 1)); done

echo
echo 'The filesystem is filled completely'
echo

echo
echo Test:
echo

rm -f mnt/small_1     # Remove file
cp small mnt/small_1  # Try recreate the same.
                      # But result will be "No space left on device"

-------------------- cut here -------------------------------------

The last command will be finished with error: "No space left on device"
I ran this script on openSUSE 12.3 (Dartmouth) (i586) with kernel 3.7.10

Thanks

                 reply	other threads:[~2015-10-14  5:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAAAVVLTY2UnU0ps6MZr2jL9MUXLDP2tGSr5gp2fJ7kzkhfuCUg@mail.gmail.com \
    --to=stvdedal@gmail.com \
    --cc=linux-mtd@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.