Skip to content

Commit b7cef0d

Browse files
committed
Merge tag 'for-linus-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs
Pull UBI and UBIFS updates from Richard Weinberger: "UBI: - Use bitmap API to allocate bitmaps - New attach mode, disable_fm, to attach without fastmap - Fixes for various typos in comments UBIFS: - Fix for a deadlock when setting xattrs for encrypted file - Fix for an assertion failures when truncating encrypted files - Fixes for various typos in comments" * tag 'for-linus-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs: ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl ubi: fastmap: Use the bitmap API to allocate bitmaps ubifs: Fix AA deadlock when setting xattr for encrypted file ubifs: Fix UBIFS ro fail due to truncate in the encrypted directory mtd: ubi: drop unexpected word 'a' in comments ubi: block: Fix typos in comments ubi: fastmap: Fix typo in comments ubi: Fix repeated words in comments ubi: ubi-media.h: Fix comment typo ubi: block: Remove in vain semicolon ubifs: Fix ubifs_check_dir_empty() kernel-doc comment
2 parents 91080ab + 669d204 commit b7cef0d

File tree

16 files changed

+84
-53
lines changed

16 files changed

+84
-53
lines changed

drivers/mtd/ubi/block.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
409409
ret = blk_mq_alloc_tag_set(&dev->tag_set);
410410
if (ret) {
411411
dev_err(disk_to_dev(dev->gd), "blk_mq_alloc_tag_set failed");
412-
goto out_free_dev;;
412+
goto out_free_dev;
413413
}
414414

415415

@@ -441,7 +441,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
441441

442442
/*
443443
* Create one workqueue per volume (per registered block device).
444-
* Rembember workqueues are cheap, they're not threads.
444+
* Remember workqueues are cheap, they're not threads.
445445
*/
446446
dev->wq = alloc_workqueue("%s", 0, 0, gd->disk_name);
447447
if (!dev->wq) {

drivers/mtd/ubi/build.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,18 +807,23 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
807807
* @ubi_num: number to assign to the new UBI device
808808
* @vid_hdr_offset: VID header offset
809809
* @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs
810+
* @disable_fm: whether disable fastmap
810811
*
811812
* This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number
812813
* to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in
813814
* which case this function finds a vacant device number and assigns it
814815
* automatically. Returns the new UBI device number in case of success and a
815816
* negative error code in case of failure.
816817
*
818+
* If @disable_fm is true, ubi doesn't create new fastmap even the module param
819+
* 'fm_autoconvert' is set, and existed old fastmap will be destroyed after
820+
* doing full scanning.
821+
*
817822
* Note, the invocations of this function has to be serialized by the
818823
* @ubi_devices_mutex.
819824
*/
820825
int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
821-
int vid_hdr_offset, int max_beb_per1024)
826+
int vid_hdr_offset, int max_beb_per1024, bool disable_fm)
822827
{
823828
struct ubi_device *ubi;
824829
int i, err;
@@ -921,7 +926,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
921926
UBI_FM_MIN_POOL_SIZE);
922927

923928
ubi->fm_wl_pool.max_size = ubi->fm_pool.max_size / 2;
924-
ubi->fm_disabled = !fm_autoconvert;
929+
ubi->fm_disabled = (!fm_autoconvert || disable_fm) ? 1 : 0;
925930
if (fm_debug)
926931
ubi_enable_dbg_chk_fastmap(ubi);
927932

@@ -962,7 +967,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
962967
if (!ubi->fm_buf)
963968
goto out_free;
964969
#endif
965-
err = ubi_attach(ubi, 0);
970+
err = ubi_attach(ubi, disable_fm ? 1 : 0);
966971
if (err) {
967972
ubi_err(ubi, "failed to attach mtd%d, error %d",
968973
mtd->index, err);
@@ -1242,7 +1247,8 @@ static int __init ubi_init(void)
12421247

12431248
mutex_lock(&ubi_devices_mutex);
12441249
err = ubi_attach_mtd_dev(mtd, p->ubi_num,
1245-
p->vid_hdr_offs, p->max_beb_per1024);
1250+
p->vid_hdr_offs, p->max_beb_per1024,
1251+
false);
12461252
mutex_unlock(&ubi_devices_mutex);
12471253
if (err < 0) {
12481254
pr_err("UBI error: cannot attach mtd%d\n",

drivers/mtd/ubi/cdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static int verify_rsvol_req(const struct ubi_device *ubi,
672672
* @req: volumes re-name request
673673
*
674674
* This is a helper function for the volume re-name IOCTL which validates the
675-
* the request, opens the volume and calls corresponding volumes management
675+
* request, opens the volume and calls corresponding volumes management
676676
* function. Returns zero in case of success and a negative error code in case
677677
* of failure.
678678
*/
@@ -1041,7 +1041,7 @@ static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
10411041
*/
10421042
mutex_lock(&ubi_devices_mutex);
10431043
err = ubi_attach_mtd_dev(mtd, req.ubi_num, req.vid_hdr_offset,
1044-
req.max_beb_per1024);
1044+
req.max_beb_per1024, !!req.disable_fm);
10451045
mutex_unlock(&ubi_devices_mutex);
10461046
if (err < 0)
10471047
put_mtd_device(mtd);

drivers/mtd/ubi/eba.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static int leb_write_lock(struct ubi_device *ubi, int vol_id, int lnum)
377377
*
378378
* This function locks a logical eraseblock for writing if there is no
379379
* contention and does nothing if there is contention. Returns %0 in case of
380-
* success, %1 in case of contention, and and a negative error code in case of
380+
* success, %1 in case of contention, and a negative error code in case of
381381
* failure.
382382
*/
383383
static int leb_write_trylock(struct ubi_device *ubi, int vol_id, int lnum)

drivers/mtd/ubi/fastmap.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
2020
if (!ubi_dbg_chk_fastmap(ubi))
2121
return NULL;
2222

23-
ret = kcalloc(BITS_TO_LONGS(ubi->peb_count), sizeof(unsigned long),
24-
GFP_KERNEL);
23+
ret = bitmap_zalloc(ubi->peb_count, GFP_KERNEL);
2524
if (!ret)
2625
return ERR_PTR(-ENOMEM);
2726

@@ -34,7 +33,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
3433
*/
3534
static inline void free_seen(unsigned long *seen)
3635
{
37-
kfree(seen);
36+
bitmap_free(seen);
3837
}
3938

4039
/**
@@ -1108,8 +1107,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
11081107
if (!ubi->fast_attach)
11091108
return 0;
11101109

1111-
vol->checkmap = kcalloc(BITS_TO_LONGS(leb_count), sizeof(unsigned long),
1112-
GFP_KERNEL);
1110+
vol->checkmap = bitmap_zalloc(leb_count, GFP_KERNEL);
11131111
if (!vol->checkmap)
11141112
return -ENOMEM;
11151113

@@ -1118,7 +1116,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
11181116

11191117
void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol)
11201118
{
1121-
kfree(vol->checkmap);
1119+
bitmap_free(vol->checkmap);
11221120
}
11231121

11241122
/**

drivers/mtd/ubi/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum,
11471147
* @ubi: UBI device description object
11481148
* @pnum: the physical eraseblock number to check
11491149
*
1150-
* This function returns zero if the erase counter header is all right and and
1150+
* This function returns zero if the erase counter header is all right and
11511151
* a negative error code if not or if an error occurred.
11521152
*/
11531153
static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)

drivers/mtd/ubi/ubi-media.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ enum {
131131
* is changed radically. This field is duplicated in the volume identifier
132132
* header.
133133
*
134-
* The @vid_hdr_offset and @data_offset fields contain the offset of the the
134+
* The @vid_hdr_offset and @data_offset fields contain the offset of the
135135
* volume identifier header and user data, relative to the beginning of the
136136
* physical eraseblock. These values have to be the same for all physical
137137
* eraseblocks.

drivers/mtd/ubi/ubi.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void ubi_err(const struct ubi_device *ubi, const char *fmt, ...);
8686
* Error codes returned by the I/O sub-system.
8787
*
8888
* UBI_IO_FF: the read region of flash contains only 0xFFs
89-
* UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also also there was a data
89+
* UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also there was a data
9090
* integrity error reported by the MTD driver
9191
* (uncorrectable ECC error in case of NAND)
9292
* UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC)
@@ -281,7 +281,7 @@ struct ubi_eba_leb_desc {
281281

282282
/**
283283
* struct ubi_volume - UBI volume description data structure.
284-
* @dev: device object to make use of the the Linux device model
284+
* @dev: device object to make use of the Linux device model
285285
* @cdev: character device object to create character device
286286
* @ubi: reference to the UBI device description object
287287
* @vol_id: volume ID
@@ -439,7 +439,7 @@ struct ubi_debug_info {
439439

440440
/**
441441
* struct ubi_device - UBI device description structure
442-
* @dev: UBI device object to use the the Linux device model
442+
* @dev: UBI device object to use the Linux device model
443443
* @cdev: character device object to create character device
444444
* @ubi_num: UBI device number
445445
* @ubi_name: UBI device name
@@ -937,7 +937,8 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
937937

938938
/* build.c */
939939
int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
940-
int vid_hdr_offset, int max_beb_per1024);
940+
int vid_hdr_offset, int max_beb_per1024,
941+
bool disable_fm);
941942
int ubi_detach_mtd_dev(int ubi_num, int anyway);
942943
struct ubi_device *ubi_get_device(int ubi_num);
943944
void ubi_put_device(struct ubi_device *ubi);

drivers/mtd/ubi/vmt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
623623
* @ubi: UBI device description object
624624
* @vol_id: volume ID
625625
*
626-
* Returns zero if volume is all right and a a negative error code if not.
626+
* Returns zero if volume is all right and a negative error code if not.
627627
*/
628628
static int self_check_volume(struct ubi_device *ubi, int vol_id)
629629
{
@@ -776,7 +776,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id)
776776
* self_check_volumes - check information about all volumes.
777777
* @ubi: UBI device description object
778778
*
779-
* Returns zero if volumes are all right and a a negative error code if not.
779+
* Returns zero if volumes are all right and a negative error code if not.
780780
*/
781781
static int self_check_volumes(struct ubi_device *ubi)
782782
{

drivers/mtd/ubi/wl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static struct ubi_wl_entry *find_mean_wl_entry(struct ubi_device *ubi,
376376
* refill_wl_user_pool().
377377
* @ubi: UBI device description object
378378
*
379-
* This function returns a a wear leveling entry in case of success and
379+
* This function returns a wear leveling entry in case of success and
380380
* NULL in case of failure.
381381
*/
382382
static struct ubi_wl_entry *wl_get_wle(struct ubi_device *ubi)
@@ -429,7 +429,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)
429429
/**
430430
* sync_erase - synchronously erase a physical eraseblock.
431431
* @ubi: UBI device description object
432-
* @e: the the physical eraseblock to erase
432+
* @e: the physical eraseblock to erase
433433
* @torture: if the physical eraseblock has to be tortured
434434
*
435435
* This function returns zero in case of success and a negative error code in
@@ -1016,7 +1016,7 @@ static int ensure_wear_leveling(struct ubi_device *ubi, int nested)
10161016

10171017
/*
10181018
* If the ubi->scrub tree is not empty, scrubbing is needed, and the
1019-
* the WL worker has to be scheduled anyway.
1019+
* WL worker has to be scheduled anyway.
10201020
*/
10211021
if (!ubi->scrub.rb_node) {
10221022
#ifdef CONFIG_MTD_UBI_FASTMAP
@@ -1464,7 +1464,7 @@ static bool scrub_possible(struct ubi_device *ubi, struct ubi_wl_entry *e)
14641464
* ubi_bitflip_check - Check an eraseblock for bitflips and scrub it if needed.
14651465
* @ubi: UBI device description object
14661466
* @pnum: the physical eraseblock to schedule
1467-
* @force: dont't read the block, assume bitflips happened and take action.
1467+
* @force: don't read the block, assume bitflips happened and take action.
14681468
*
14691469
* This function reads the given eraseblock and checks if bitflips occured.
14701470
* In case of bitflips, the eraseblock is scheduled for scrubbing.

fs/ubifs/crypto.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ static bool ubifs_crypt_empty_dir(struct inode *inode)
2424
return ubifs_check_dir_empty(inode) == 0;
2525
}
2626

27+
/**
28+
* ubifs_encrypt - Encrypt data.
29+
* @inode: inode which refers to the data node
30+
* @dn: data node to encrypt
31+
* @in_len: length of data to be compressed
32+
* @out_len: allocated memory size for the data area of @dn
33+
* @block: logical block number of the block
34+
*
35+
* This function encrypt a possibly-compressed data in the data node.
36+
* The encrypted data length will store in @out_len.
37+
*/
2738
int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn,
2839
unsigned int in_len, unsigned int *out_len, int block)
2940
{

fs/ubifs/dir.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ static int inherit_flags(const struct inode *dir, umode_t mode)
6868
* @c: UBIFS file-system description object
6969
* @dir: parent directory inode
7070
* @mode: inode mode flags
71+
* @is_xattr: whether the inode is xattr inode
7172
*
7273
* This function finds an unused inode number, allocates new inode and
7374
* initializes it. Returns new inode in case of success and an error code in
7475
* case of failure.
7576
*/
7677
struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
77-
umode_t mode)
78+
umode_t mode, bool is_xattr)
7879
{
7980
int err;
8081
struct inode *inode;
@@ -99,10 +100,12 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
99100
current_time(inode);
100101
inode->i_mapping->nrpages = 0;
101102

102-
err = fscrypt_prepare_new_inode(dir, inode, &encrypted);
103-
if (err) {
104-
ubifs_err(c, "fscrypt_prepare_new_inode failed: %i", err);
105-
goto out_iput;
103+
if (!is_xattr) {
104+
err = fscrypt_prepare_new_inode(dir, inode, &encrypted);
105+
if (err) {
106+
ubifs_err(c, "fscrypt_prepare_new_inode failed: %i", err);
107+
goto out_iput;
108+
}
106109
}
107110

108111
switch (mode & S_IFMT) {
@@ -309,7 +312,7 @@ static int ubifs_create(struct user_namespace *mnt_userns, struct inode *dir,
309312

310313
sz_change = CALC_DENT_SIZE(fname_len(&nm));
311314

312-
inode = ubifs_new_inode(c, dir, mode);
315+
inode = ubifs_new_inode(c, dir, mode, false);
313316
if (IS_ERR(inode)) {
314317
err = PTR_ERR(inode);
315318
goto out_fname;
@@ -370,7 +373,7 @@ static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry)
370373
if (err)
371374
return ERR_PTR(err);
372375

373-
inode = ubifs_new_inode(c, dir, mode);
376+
inode = ubifs_new_inode(c, dir, mode, false);
374377
if (IS_ERR(inode)) {
375378
err = PTR_ERR(inode);
376379
goto out_free;
@@ -463,7 +466,7 @@ static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
463466
return err;
464467
}
465468

466-
inode = ubifs_new_inode(c, dir, mode);
469+
inode = ubifs_new_inode(c, dir, mode, false);
467470
if (IS_ERR(inode)) {
468471
err = PTR_ERR(inode);
469472
goto out_budg;
@@ -873,7 +876,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
873876
}
874877

875878
/**
876-
* check_dir_empty - check if a directory is empty or not.
879+
* ubifs_check_dir_empty - check if a directory is empty or not.
877880
* @dir: VFS inode object of the directory to check
878881
*
879882
* This function checks if directory @dir is empty. Returns zero if the
@@ -1005,7 +1008,7 @@ static int ubifs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
10051008

10061009
sz_change = CALC_DENT_SIZE(fname_len(&nm));
10071010

1008-
inode = ubifs_new_inode(c, dir, S_IFDIR | mode);
1011+
inode = ubifs_new_inode(c, dir, S_IFDIR | mode, false);
10091012
if (IS_ERR(inode)) {
10101013
err = PTR_ERR(inode);
10111014
goto out_fname;
@@ -1092,7 +1095,7 @@ static int ubifs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
10921095

10931096
sz_change = CALC_DENT_SIZE(fname_len(&nm));
10941097

1095-
inode = ubifs_new_inode(c, dir, mode);
1098+
inode = ubifs_new_inode(c, dir, mode, false);
10961099
if (IS_ERR(inode)) {
10971100
kfree(dev);
10981101
err = PTR_ERR(inode);
@@ -1174,7 +1177,7 @@ static int ubifs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
11741177

11751178
sz_change = CALC_DENT_SIZE(fname_len(&nm));
11761179

1177-
inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO);
1180+
inode = ubifs_new_inode(c, dir, S_IFLNK | S_IRWXUGO, false);
11781181
if (IS_ERR(inode)) {
11791182
err = PTR_ERR(inode);
11801183
goto out_fname;

0 commit comments

Comments
 (0)