07 Nov, 2014
4 commits
-
The logic of vfree()'ing vol->upd_buf is tied to vol->updating.
In ubi_start_update() vol->updating is set long before vmalloc()'ing
vol->upd_buf. If we encounter a write failure in ubi_start_update()
before vmalloc() the UBI device release function will try to vfree()
vol->upd_buf because vol->updating is set.
Fix this by allocating vol->upd_buf directly after setting vol->updating.Fixes:
[ 31.559338] UBI warning: vol_cdev_release: update of volume 2 not finished, volume is damaged
[ 31.559340] ------------[ cut here ]------------
[ 31.559343] WARNING: CPU: 1 PID: 2747 at mm/vmalloc.c:1446 __vunmap+0xe3/0x110()
[ 31.559344] Trying to vfree() nonexistent vm area (ffffc90001f2b000)
[ 31.559345] Modules linked in:
[ 31.565620] 0000000000000bba ffff88002a0cbdb0 ffffffff818f0497 ffff88003b9ba148
[ 31.566347] ffff88002a0cbde0 ffffffff8156f515 ffff88003b9ba148 0000000000000bba
[ 31.567073] 0000000000000000 0000000000000000 ffff88002a0cbe88 ffffffff8156c10a
[ 31.567793] Call Trace:
[ 31.568034] [] dump_stack+0x4e/0x7a
[ 31.568510] [] ubi_io_write_vid_hdr+0x155/0x160
[ 31.569084] [] ubi_eba_write_leb+0x23a/0x870
[ 31.569628] [] vol_cdev_write+0x226/0x380
[ 31.570155] [] vfs_write+0xb5/0x1f0
[ 31.570627] [] SyS_pwrite64+0x6a/0xa0
[ 31.571123] [] system_call_fastpath+0x16/0x1bCc:
Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy -
If the erase worker is unable to erase a PEB it will
free the ubi_wl_entry itself.
The failing ubi_wl_entry must not free()'d again after
do_sync_erase() returns.Cc:
Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy -
This is more a cosmetic change than a fix.
By using ubi_eba_atomic_leb_change()
we can guarantee that the first VTBL record is always
correct and we don't really need the second one anymore.
But we have to keep the second one to not break anything.Artem: add a comment
Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy -
If there is more then one UBI device mounted, there is no way to
distinguish between messages from different UBI devices.
Add device number to all ubi layer message types.The R/O block driver messages were replaced by pr_* since
ubi_device structure is not used by it.Amended a bit by Artem.
Signed-off-by: Tanya Brokhman
Signed-off-by: Artem Bityutskiy
03 Oct, 2014
1 commit
-
We need to add fm_sb too.
Signed-off-by: Richard Weinberger
Reviewed-by: Tanya Brokhman
Signed-off-by: Artem Bityutskiy
30 Sep, 2014
1 commit
-
s/of/if/
Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
26 Sep, 2014
2 commits
-
It confused me more than once that the cancel flag of the
work function does not indicate the cancellation of a single work.
In fact it indicates the WL sub-system shutdown and therefore
worker functions have to free their wl_entries too.
That's why you cannot cancel a single work, you can only shutdown
all works.Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy -
There is no need to set err, it will be overwritten in any case
later at:
if (scrub)
err = ubi_wl_scrub_peb(ubi, pnum);Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
24 Sep, 2014
1 commit
-
The while loop in produce_free_peb() assumes that each work will produce a
free PEB. This is not true.
If ubi->works_count is 1 and the only scheduled work is the
wear_leveling_worker() produce_free_peb() can loop forever in case
nobody schedules an erase work.
Fix this issue by checking in the while loop whether work is scheduled.Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
19 Sep, 2014
2 commits
-
I noticed this during a code review. We are checking that the strlen()
of ->name is not less than the ->name_len which the user gave us. I
believe this bug is harmless but clearly we meant to return here instead
of setting an error code and then not using it.Signed-off-by: Dan Carpenter
Signed-off-by: Artem Bityutskiy -
Make clear what work_sem really does.
Suggested-by: Artem Bityutskiy
Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
17 Sep, 2014
4 commits
-
The UBI_IOCVOLUP ioctl is used to start an update and also to
truncate a volume. In the first case, a "volume updated" notification
is dispatched when the update is done.This commit adds the "volume updated" notification to be also sent when
the volume is truncated. This is required for UBI block and gluebi to get
notified about the new volume size.Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
Cc: stable@vger.kernel.org # v3.15+ -
Static volumes can change its 'used_bytes' when they get updated,
and so the block interface must listen to the UBI_VOLUME_UPDATED
notification to resize the block device accordingly.Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
Cc: stable@vger.kernel.org # v3.15+ -
We are currently taking the block device size from the ubi_volume_info.size
field. However, this is not the amount of data in the volume, but the
number of reserved physical eraseblocks, and hence leads to an incorrect
representation of the volume.In particular, this produces I/O errors on static volumes as the block
interface may attempt to read unmapped PEBs:$ cat /dev/ubiblock0_0 > /dev/null
UBI error: ubiblock_read_to_buf: ubiblock0_0 ubi_read error -22
end_request: I/O error, dev ubiblock0_0, sector 9536
Buffer I/O error on device ubiblock0_0, logical block 2384
[snip]Fix this by using the ubi_volume_info.used_bytes field which is set to the
actual number of data bytes for both static and dynamic volumes.While here, improve the error message to be less stupid and more useful:
UBI error: ubiblock_read_to_buf: ubiblock0_1 ubi_read error -9 on LEB=0, off=15872, len=512It's worth noticing that the 512-byte sector representation of the volume
is only correct if the volume size is multiple of 512-bytes. This is true for
virtually any NAND device, given eraseblocks and pages are 512-byte multiple
and hence so is the LEB size.Artem: tweak the error message and make it look more like other UBI error
messages.Fixes: 9d54c8a33eec ("UBI: R/O block driver on top of UBI volumes")
Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
Cc: stable@vger.kernel.org # v3.15+ -
commit 4df38926f337 ("UBI: block: Avoid disk size integer overflow")
introduced a dereference on dev (which is not initialized at that
point) when printing a warning message. Re-order disk_capacity check
after the dev is found.Found by cppcheck:
[drivers/mtd/ubi/block.c:509]: (error) Uninitialized variable: devArtem: tweak the error message a bit
Signed-off-by: Colin Ian King
Acked-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
16 Sep, 2014
1 commit
-
I ran into this error after a ubiupdatevol, because I forgot to backport
e9110361a9a4 UBI: fix the volumes tree sorting criteria.UBI error: process_pool_aeb: orphaned volume in fastmap pool
UBI error: ubi_scan_fastmap: Attach by fastmap failed, doing a full scan!
kmem_cache_destroy ubi_ainf_peb_slab: Slab cache still has objects
CPU: 0 PID: 1 Comm: swapper Not tainted 3.14.18-00053-gf05cac8dbf85 #1
[] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[] (show_stack) from [] (destroy_ai+0x230/0x244)
[] (destroy_ai) from [] (ubi_attach+0x98/0x1ec)
[] (ubi_attach) from [] (ubi_attach_mtd_dev+0x2b8/0x868)
[] (ubi_attach_mtd_dev) from [] (ubi_init+0x1dc/0x2ac)
[] (ubi_init) from [] (do_one_initcall+0x94/0x140)
[] (do_one_initcall) from [] (kernel_init_freeable+0xe8/0x1b0)
[] (kernel_init_freeable) from [] (kernel_init+0x8/0xe4)
[] (kernel_init) from [] (ret_from_fork+0x14/0x24)
UBI: scanning is finishedFreeing the cache in the error path fixes the Slab error.
Tested on at91sam9g35 (3.14.18+fastmap backports)
Signed-off-by: Richard Genoud
Cc: stable # 3.10+
29 Jul, 2014
1 commit
-
Use the _safe variant because we're iterating over a list where items get
deleted and freed.Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
28 Jul, 2014
3 commits
-
This patch fixes the issue that on very large UBI volumes
UBI block does not work correctly.Signed-off-by: Richard Weinberger
Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy -
There's no need to set the disk capacity with the mutex held, so this
commit takes the variable setting out of the mutex. This simplifies
the disk capacity fix for very large volumes in a follow up commit.Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy -
Currently, ubiblock_resize() can fail if the device is not found
in the list. This commit changes the return type, so the function can
return something meaningful on error paths.Reported-by: kbuild test robot
Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
19 Jul, 2014
1 commit
-
UBI assumes that ubi_attach_info will only contain ubi_ainf_volume
structures for volumes with at least one LEB.
In scanning mode this is true because UBI can nicely create a ubi_ainf_volume
on demand while creating the EBA table.For fastmap this is not true, the fastmap on-flash structure has a list of
all volumes, the ubi_ainf_volume structures are created from this list.
So it can happen that an empty volume ends up in init_volumes().We can easely deal with that by looking into ->leb_count too.
Signed-off-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
16 Jul, 2014
1 commit
-
The return value from 'ubi_io_read_ec_hdr()' was stored in 'err', not in 'ret'.
This fix makes sure Fastmap-enabled UBI does not miss bit-flip while reading EC
headers, events and scrubs the affected PEBs.This issue was reported by Coverity Scan.
Artem: improved the commit message.
Signed-off-by: Brian Norris
Acked-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
01 Jul, 2014
1 commit
-
Commig "604b592 UBI: fix rb_tree node comparison in add_map"
broke fastmap backward compatibility and older fastmap images
cannot be mounted anymore. The reason is that it changes the
volumes RB-tree sorting criteria. This patch fixes the problem.Artem: re-write the commit message
Signed-off-by: Heiko Schocher
Acked-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
10 Jun, 2014
1 commit
-
Pull UBIFS updates from Artem Bityutskiy:
"This contains several UBIFS fixes. One of them fixes a race condition
between the mmap page fault path and fsync. Another just removes a
bogus assertion from the UBIFS memory shrinker.UBIFS also started honoring the MS_SILENT mount flag, so now it won't
print many I/O errors when user-space just tries to probe for the FS.Rest of the changes are rather minor UBI/UBIFS fixes, improvements,
and clean-ups"* tag 'upstream-3.16-rc1-v2' of git://git.infradead.org/linux-ubifs:
UBIFS: Add an assertion for clean_zn_cnt
UBIFS: respect MS_SILENT mount flag
UBIFS: Remove incorrect assertion in shrink_tnc()
UBIFS: fix debugging check
UBIFS: add missing ui pointer in debugging code
UBI: block: Fix error path on alloc_workqueue failure
UBIFS: Fix dump messages in ubifs_dump_lprops
UBI: fix rb_tree node comparison in add_map
UBIFS: Remove unused variables in ubifs_budget_space
UBI: weaken the 'exclusive' constraint when opening volumes to rename
UBIFS: fix an mmap and fsync race condition
03 Jun, 2014
1 commit
-
Pull block core updates from Jens Axboe:
"It's a big(ish) round this time, lots of development effort has gone
into blk-mq in the last 3 months. Generally we're heading to where
3.16 will be a feature complete and performant blk-mq. scsi-mq is
progressing nicely and will hopefully be in 3.17. A nvme port is in
progress, and the Micron pci-e flash driver, mtip32xx, is converted
and will be sent in with the driver pull request for 3.16.This pull request contains:
- Lots of prep and support patches for scsi-mq have been integrated.
All from Christoph.- API and code cleanups for blk-mq from Christoph.
- Lots of good corner case and error handling cleanup fixes for
blk-mq from Ming Lei.- A flew of blk-mq updates from me:
* Provide strict mappings so that the driver can rely on the CPU
to queue mapping. This enables optimizations in the driver.* Provided a bitmap tagging instead of percpu_ida, which never
really worked well for blk-mq. percpu_ida relies on the fact
that we have a lot more tags available than we really need, it
fails miserably for cases where we exhaust (or are close to
exhausting) the tag space.* Provide sane support for shared tag maps, as utilized by scsi-mq
* Various fixes for IO timeouts.
* API cleanups, and lots of perf tweaks and optimizations.
- Remove 'buffer' from struct request. This is ancient code, from
when requests were always virtually mapped. Kill it, to reclaim
some space in struct request. From me.- Remove 'magic' from blk_plug. Since we store these on the stack
and since we've never caught any actual bugs with this, lets just
get rid of it. From me.- Only call part_in_flight() once for IO completion, as includes two
atomic reads. Hopefully we'll get a better implementation soon, as
the part IO stats are now one of the more expensive parts of doing
IO on blk-mq. From me.- File migration of block code from {mm,fs}/ to block/. This
includes bio.c, bio-integrity.c, bounce.c, and ioprio.c. From me,
from a discussion on lkml.That should describe the meat of the pull request. Also has various
little fixes and cleanups from Dave Jones, Shaohua Li, Duan Jiong,
Fengguang Wu, Fabian Frederick, Randy Dunlap, Robert Elliott, and Sam
Bradshaw"* 'for-3.16/core' of git://git.kernel.dk/linux-block: (100 commits)
blk-mq: push IPI or local end_io decision to __blk_mq_complete_request()
blk-mq: remember to start timeout handler for direct queue
block: ensure that the timer is always added
blk-mq: blk_mq_unregister_hctx() can be static
blk-mq: make the sysfs mq/ layout reflect current mappings
blk-mq: blk_mq_tag_to_rq should handle flush request
block: remove dead code in scsi_ioctl:blk_verify_command
blk-mq: request initialization optimizations
block: add queue flag for disabling SG merging
block: remove 'magic' from struct blk_plug
blk-mq: remove alloc_hctx and free_hctx methods
blk-mq: add file comments and update copyright notices
blk-mq: remove blk_mq_alloc_request_pinned
blk-mq: do not use blk_mq_alloc_request_pinned in blk_mq_map_request
blk-mq: remove blk_mq_wait_for_tags
blk-mq: initialize request in __blk_mq_alloc_request
blk-mq: merge blk_mq_alloc_reserved_request into blk_mq_alloc_request
blk-mq: add helper to insert requests from irq context
blk-mq: remove stale comment for blk_mq_complete_request()
blk-mq: allow non-softirq completions
...
27 May, 2014
1 commit
-
Otherwise we'd return a random value if allocation of the workqueue fails.
Signed-off-by: Helmut Schaa
Acked-by: Brian Norris
Signed-off-by: Artem Bityutskiy
13 May, 2014
2 commits
-
The comparisons used in add_vol() shouldn't be identical. Pretty sure
the following is correct but it is completely untested.Signed-off-by: Mike Snitzer
Acked-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy -
The UBI volume rename ioctl (UBI_IOCRNVOL) open the volumes in exclusive
mode. The volumes are opened for two reasons: to build a volume rename list,
and a volume remove list.However, the first open constraint is excessive and can be replaced by
a 'read-write' open mode. The second open constraint is properly set as
'exclusive' given the volume is opened for removal and we don't want any
users around.By weakening the former 'exclusive' mode, we allow 'read-only' users to keep
the volume open, while a rename is taking place. This is useful to perform
an atomic rename, in a firmware upgrade scenario, while keeping the volume
in read-only use (for instance, if a ubiblock is mounted as rootfs).It's worth mention this is not the case of UBIFS, which keeps the volume
opened as 'read-write' despite mounted as read-write or read-only mode.This change was suggested at least twice by Artem:
http://lists.infradead.org/pipermail/linux-mtd/2012-September/044175.html
http://permalink.gmane.org/gmane.linux.drivers.mtd/39866Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
05 May, 2014
3 commits
-
When building the name for the workqueue thread, make sure a format
string cannot leak in from the disk name.Signed-off-by: Kees Cook
Signed-off-by: Artem Bityutskiy -
The ubi->free_count should be updated with every insert/remove to/from
the ubi->free list.Signed-off-by: Tanya Brokhman
Reviewed-by: Dolev Raviv
Acked-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy -
In case of an error (if there are not free PEB's for example),
__wl_get_peb will return a negative value. In order to prevent access
violation we need to test the returned value prior to using it later on.Signed-off-by: Tatyana Brokhman
Reviewed-by: Dolev Raviv
Acked-by: Richard Weinberger
Signed-off-by: Artem Bityutskiy
16 Apr, 2014
1 commit
-
This was used in the olden days, back when onions were proper
yellow. Basically it mapped to the current buffer to be
transferred. With highmem being added more than a decade ago,
most drivers map pages out of a bio, and rq->buffer isn't
pointing at anything valid.Convert old style drivers to just use bio_data().
For the discard payload use case, just reference the page
in the bio.Signed-off-by: Jens Axboe
08 Apr, 2014
1 commit
-
Pull MTD updates from Brian Norris:
- A few SPI NOR ID definitions
- Kill the NAND "max pagesize" restriction
- Fix some x16 bus-width NAND support
- Add NAND JEDEC parameter page support
- DT bindings for NAND ECC
- GPMI NAND updates (subpage reads)
- More OMAP NAND refactoring
- New STMicro SPI NOR driver (now in 40 patches!)
- A few other random bugfixes* tag 'for-linus-20140405' of git://git.infradead.org/linux-mtd: (120 commits)
Fix index regression in nand_read_subpage
mtd: diskonchip: mem resource name is not optional
mtd: nand: fix mention to CONFIG_MTD_NAND_ECC_BCH
mtd: nand: fix GET/SET_FEATURES address on 16-bit devices
mtd: omap2: Use devm_ioremap_resource()
mtd: denali_dt: Use devm_ioremap_resource()
mtd: devices: elm: update DRIVER_NAME as "omap-elm"
mtd: devices: elm: configure parallel channels based on ecc_steps
mtd: devices: elm: clean elm_load_syndrome
mtd: devices: elm: check for hardware engine's design constraints
mtd: st_spi_fsm: Succinctly reorganise .remove()
mtd: st_spi_fsm: Allow loop to run at least once before giving up CPU
mtd: st_spi_fsm: Correct vendor name spelling issue - missing "M"
mtd: st_spi_fsm: Avoid duplicating MTD core code
mtd: st_spi_fsm: Remove useless consts from function arguments
mtd: st_spi_fsm: Convert ST SPI FSM (NOR) Flash driver to new DT partitions
mtd: st_spi_fsm: Move runtime configurable msg sequences into device's struct
mtd: st_spi_fsm: Supply the W25Qxxx chip specific configuration call-back
mtd: st_spi_fsm: Supply the S25FLxxx chip specific configuration call-back
mtd: st_spi_fsm: Supply the MX25xxx chip specific configuration call-back
...
22 Mar, 2014
1 commit
-
You cannot mark these parameters as __initdata.
Otherwise the data is gone upon module exit.Fixes:
[ 172.045465] BUG: unable to handle kernel paging request at ffffffffa001db38
[ 172.046020] IP: [] destroy_params+0x24/0x50Signed-off-by: Richard Weinberger
Acked-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
11 Mar, 2014
1 commit
-
None of these files are actually using any __init type directives
and hence don't need to include . Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.Cc: David Woodhouse
Cc: Brian Norris
Cc: linux-mtd@lists.infradead.org
Signed-off-by: Paul Gortmaker
[Brian: dropped one incorrect hunk]
Signed-off-by: Brian Norris
05 Mar, 2014
2 commits
-
Rename the UBI_IOCVOLATTBLK and UBI_IOCVOLDETBLK to UBI_IOCVOLCRBLK and
UBI_IOCVOLRMBLK, because we do not use terms "attach" and "detach" for the R/O
block devices on top of UBI volumes. Instead, we use terms "create" and
"remove". This patch also amends the related commentaries.Signed-off-by: Artem Bityutskiy
Acked-by: Ezequiel Garcia -
In order to have a way of distinguishing an invalid ioctl from a
not supported (but otherwise valid) ioctl, this commit changes the
return value of the ioctl stubs from ENOTTY to ENOSYS.This will be useful to report more accurate error messages from
userspace tools.Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy
04 Mar, 2014
3 commits
-
The UBI block driver depends on the block infrastructure. Add the
proper dependency and fix a build error when CONFIG_BLOCK is not selected.Reported-by: kbuild test robot
Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy -
Fixes the following warning on ARCH=avr32:
drivers/mtd/ubi/block.c: In function 'ubiblock_read':
drivers/mtd/ubi/block.c:207: warning: comparison of distinct pointer types lacks a castReported-by: kbuild test robot
Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy -
ubiblock_param_ops should be marked as __init as it's only used to set
a driver parameter on insertion time. This commit fixes the following:WARNING: drivers/mtd/built-in.o(.text+0x653ac): Section mismatch in
reference from the variable ubiblock_param_ops to the function
.init.text:ubiblock_set_param()The function ubiblock_param_ops() references the function __init
ubiblock_set_param(). This is often because ubiblock_param_ops lacks a
__init annotation or the annotation of ubiblock_set_param is wrong.Given gcc errors if the struct is marked const __initdata, this commit
drops the const mark from it.Reported-by: kbuild test robot
Signed-off-by: Ezequiel Garcia
Signed-off-by: Artem Bityutskiy