Skip to content

Commit d53b47c

Browse files
committed
Merge tag 'upstream-3.16-rc1-v2' of git://git.infradead.org/linux-ubifs
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
2 parents a3c5493 + 380347e commit d53b47c

11 files changed

Lines changed: 41 additions & 20 deletions

File tree

‎drivers/mtd/ubi/block.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,10 @@ int ubiblock_create(struct ubi_volume_info *vi)
432432
* Rembember workqueues are cheap, they're not threads.
433433
*/
434434
dev->wq = alloc_workqueue("%s", 0, 0, gd->disk_name);
435-
if (!dev->wq)
435+
if (!dev->wq) {
436+
ret = -ENOMEM;
436437
goto out_free_queue;
438+
}
437439
INIT_WORK(&dev->work, ubiblock_do_work);
438440

439441
mutex_lock(&devices_mutex);

‎drivers/mtd/ubi/cdev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static int rename_volumes(struct ubi_device *ubi,
731731
goto out_free;
732732
}
733733

734-
re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_EXCLUSIVE);
734+
re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_READWRITE);
735735
if (IS_ERR(re->desc)) {
736736
err = PTR_ERR(re->desc);
737737
ubi_err("cannot open volume %d, error %d", vol_id, err);

‎drivers/mtd/ubi/fastmap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id,
125125
parent = *p;
126126
av = rb_entry(parent, struct ubi_ainf_volume, rb);
127127

128-
if (vol_id > av->vol_id)
128+
if (vol_id < av->vol_id)
129129
p = &(*p)->rb_left;
130-
else if (vol_id > av->vol_id)
130+
else
131131
p = &(*p)->rb_right;
132132
}
133133

‎fs/ubifs/budget.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ static int calc_dd_growth(const struct ubifs_info *c,
437437
*/
438438
int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
439439
{
440-
int uninitialized_var(cmt_retries), uninitialized_var(wb_retries);
441440
int err, idx_growth, data_growth, dd_growth, retried = 0;
442441

443442
ubifs_assert(req->new_page <= 1);

‎fs/ubifs/debug.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,10 @@ void ubifs_dump_lprops(struct ubifs_info *c)
745745

746746
for (lnum = c->main_first; lnum < c->leb_cnt; lnum++) {
747747
err = ubifs_read_one_lp(c, lnum, &lp);
748-
if (err)
748+
if (err) {
749749
ubifs_err("cannot read lprops for LEB %d", lnum);
750+
continue;
751+
}
750752

751753
ubifs_dump_lprop(c, &lp);
752754
}

‎fs/ubifs/file.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,9 @@ static int do_writepage(struct page *page, int len)
903903
struct ubifs_info *c = inode->i_sb->s_fs_info;
904904

905905
#ifdef UBIFS_DEBUG
906+
struct ubifs_inode *ui = ubifs_inode(inode);
906907
spin_lock(&ui->ui_lock);
907-
ubifs_assert(page->index <= ui->synced_i_size << PAGE_CACHE_SIZE);
908+
ubifs_assert(page->index <= ui->synced_i_size >> PAGE_CACHE_SHIFT);
908909
spin_unlock(&ui->ui_lock);
909910
#endif
910911

@@ -1525,8 +1526,7 @@ static int ubifs_vm_page_mkwrite(struct vm_area_struct *vma,
15251526
}
15261527

15271528
wait_for_stable_page(page);
1528-
unlock_page(page);
1529-
return 0;
1529+
return VM_FAULT_LOCKED;
15301530

15311531
out_unlock:
15321532
unlock_page(page);

‎fs/ubifs/io.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -988,30 +988,32 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
988988
return err;
989989

990990
if (type != ch->node_type) {
991-
ubifs_err("bad node type (%d but expected %d)",
992-
ch->node_type, type);
991+
ubifs_errc(c, "bad node type (%d but expected %d)",
992+
ch->node_type, type);
993993
goto out;
994994
}
995995

996996
err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
997997
if (err) {
998-
ubifs_err("expected node type %d", type);
998+
ubifs_errc(c, "expected node type %d", type);
999999
return err;
10001000
}
10011001

10021002
l = le32_to_cpu(ch->len);
10031003
if (l != len) {
1004-
ubifs_err("bad node length %d, expected %d", l, len);
1004+
ubifs_errc(c, "bad node length %d, expected %d", l, len);
10051005
goto out;
10061006
}
10071007

10081008
return 0;
10091009

10101010
out:
1011-
ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
1012-
ubi_is_mapped(c->ubi, lnum));
1013-
ubifs_dump_node(c, buf);
1014-
dump_stack();
1011+
ubifs_errc(c, "bad node at LEB %d:%d, LEB mapping status %d", lnum,
1012+
offs, ubi_is_mapped(c->ubi, lnum));
1013+
if (!c->probing) {
1014+
ubifs_dump_node(c, buf);
1015+
dump_stack();
1016+
}
10151017
return -EINVAL;
10161018
}
10171019

‎fs/ubifs/shrinker.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention)
128128
freed = ubifs_destroy_tnc_subtree(znode);
129129
atomic_long_sub(freed, &ubifs_clean_zn_cnt);
130130
atomic_long_sub(freed, &c->clean_zn_cnt);
131-
ubifs_assert(atomic_long_read(&c->clean_zn_cnt) >= 0);
132131
total_freed += freed;
133132
znode = zprev;
134133
}

‎fs/ubifs/super.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,9 @@ static int mount_ubifs(struct ubifs_info *c)
11491149
size_t sz;
11501150

11511151
c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY);
1152+
/* Suppress error messages while probing if MS_SILENT is set */
1153+
c->probing = !!(c->vfs_sb->s_flags & MS_SILENT);
1154+
11521155
err = init_constants_early(c);
11531156
if (err)
11541157
return err;
@@ -1214,6 +1217,8 @@ static int mount_ubifs(struct ubifs_info *c)
12141217
if (err)
12151218
goto out_free;
12161219

1220+
c->probing = 0;
1221+
12171222
/*
12181223
* Make sure the compressor which is set as default in the superblock
12191224
* or overridden by mount options is actually compiled in.

‎fs/ubifs/tnc.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,10 +2859,11 @@ void ubifs_tnc_close(struct ubifs_info *c)
28592859
{
28602860
tnc_destroy_cnext(c);
28612861
if (c->zroot.znode) {
2862-
long n;
2862+
long n, freed;
28632863

2864-
ubifs_destroy_tnc_subtree(c->zroot.znode);
28652864
n = atomic_long_read(&c->clean_zn_cnt);
2865+
freed = ubifs_destroy_tnc_subtree(c->zroot.znode);
2866+
ubifs_assert(freed == n);
28662867
atomic_long_sub(n, &ubifs_clean_zn_cnt);
28672868
}
28682869
kfree(c->gap_lebs);

0 commit comments

Comments
 (0)