mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
274978f173
-----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEq1nRK9aeMoq1VSgcnJ2qBz9kQNkFAmPvZWkACgkQnJ2qBz9k QNkVtQf/V515KIb7lEkwOjlF7AQg5MS/c8zuodHISzWYhZyd0KSTb+qnF/QzLvVm cJ3cIPXrIyVw4Eeqh0qQvukOYCcBvUa1IBW5kePiy3mHiHRD2PRgaxSGBXTXqqPG xXagwllrn3/mG4ZKXlNYFrzgoshSFFeBdkLGEi+/L6DAe0B+mG+FIHON1eWylgOT j1D+/k9RNvRhRU8WtStcI4u9mnVPqUI2RSWUpjxuNzUPtyFflPVNCz+bkXXovPQ0 ZQY2HeZcs7jsorCmeSHUzTt5bbj3BfhO3uWL4/wnHgp+88OBRUUyvMrNbOF97xd6 KFqbJVQbSevasUSEvCS+3+EChzjGoA== =DaJi -----END PGP SIGNATURE----- Merge tag 'fixes_for_v6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs Pull UDF and ext2 fixes from Jan Kara: - Rewrite of udf directory iteration code to address multiple syzbot reports - Fixes to udf extent handling and block mapping code to address several syzbot reports and filesystem corruption issues uncovered by fsx & fsstress - Convert udf to kmap_local() - Add sanity checks when loading udf bitmaps - Drop old VARCONV support which I've never seen used and which was broken for quite some years without anybody noticing - Finish conversion of ext2 to kmap_local() - One fix to mpage_writepages() on which other udf fixes depend * tag 'fixes_for_v6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: (78 commits) udf: Avoid directory type conversion failure due to ENOMEM udf: Use unsigned variables for size calculations udf: remove reporting loc in debug output udf: Check consistency of Space Bitmap Descriptor udf: Fix file counting in LVID udf: Limit file size to 4TB udf: Don't return bh from udf_expand_dir_adinicb() udf: Convert udf_expand_file_adinicb() to avoid kmap_atomic() udf: Convert udf_adinicb_writepage() to memcpy_to_page() udf: Switch udf_adinicb_readpage() to kmap_local_page() udf: Move udf_adinicb_readpage() to inode.c udf: Mark aops implementation static udf: Switch to single address_space_operations udf: Add handling of in-ICB files to udf_bmap() udf: Convert all file types to use udf_write_end() udf: Convert in-ICB files to use udf_write_begin() udf: Convert in-ICB files to use udf_direct_IO() udf: Convert in-ICB files to use udf_writepages() udf: Unify .read_folio for normal and in-ICB files udf: Fix off-by-one error when discarding preallocation ...
118 lines
2.9 KiB
C
118 lines
2.9 KiB
C
/*
|
|
* ialloc.c
|
|
*
|
|
* PURPOSE
|
|
* Inode allocation handling routines for the OSTA-UDF(tm) filesystem.
|
|
*
|
|
* COPYRIGHT
|
|
* This file is distributed under the terms of the GNU General Public
|
|
* License (GPL). Copies of the GPL can be obtained from:
|
|
* ftp://prep.ai.mit.edu/pub/gnu/GPL
|
|
* Each contributing author retains all rights to their own work.
|
|
*
|
|
* (C) 1998-2001 Ben Fennema
|
|
*
|
|
* HISTORY
|
|
*
|
|
* 02/24/99 blf Created.
|
|
*
|
|
*/
|
|
|
|
#include "udfdecl.h"
|
|
#include <linux/fs.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include "udf_i.h"
|
|
#include "udf_sb.h"
|
|
|
|
void udf_free_inode(struct inode *inode)
|
|
{
|
|
udf_free_blocks(inode->i_sb, NULL, &UDF_I(inode)->i_location, 0, 1);
|
|
}
|
|
|
|
struct inode *udf_new_inode(struct inode *dir, umode_t mode)
|
|
{
|
|
struct super_block *sb = dir->i_sb;
|
|
struct udf_sb_info *sbi = UDF_SB(sb);
|
|
struct inode *inode;
|
|
udf_pblk_t block;
|
|
uint32_t start = UDF_I(dir)->i_location.logicalBlockNum;
|
|
struct udf_inode_info *iinfo;
|
|
struct udf_inode_info *dinfo = UDF_I(dir);
|
|
int err;
|
|
|
|
inode = new_inode(sb);
|
|
|
|
if (!inode)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
iinfo = UDF_I(inode);
|
|
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
|
|
iinfo->i_efe = 1;
|
|
if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
|
|
sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
|
|
iinfo->i_data = kzalloc(inode->i_sb->s_blocksize -
|
|
sizeof(struct extendedFileEntry),
|
|
GFP_KERNEL);
|
|
} else {
|
|
iinfo->i_efe = 0;
|
|
iinfo->i_data = kzalloc(inode->i_sb->s_blocksize -
|
|
sizeof(struct fileEntry),
|
|
GFP_KERNEL);
|
|
}
|
|
if (!iinfo->i_data) {
|
|
make_bad_inode(inode);
|
|
iput(inode);
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
err = -ENOSPC;
|
|
block = udf_new_block(dir->i_sb, NULL,
|
|
dinfo->i_location.partitionReferenceNum,
|
|
start, &err);
|
|
if (err) {
|
|
make_bad_inode(inode);
|
|
iput(inode);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
iinfo->i_unique = lvid_get_unique_id(sb);
|
|
inode->i_generation = iinfo->i_unique;
|
|
|
|
inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
|
|
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
|
|
inode->i_uid = sbi->s_uid;
|
|
if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
|
|
inode->i_gid = sbi->s_gid;
|
|
|
|
iinfo->i_location.logicalBlockNum = block;
|
|
iinfo->i_location.partitionReferenceNum =
|
|
dinfo->i_location.partitionReferenceNum;
|
|
inode->i_ino = udf_get_lb_pblock(sb, &iinfo->i_location, 0);
|
|
inode->i_blocks = 0;
|
|
iinfo->i_lenEAttr = 0;
|
|
iinfo->i_lenAlloc = 0;
|
|
iinfo->i_use = 0;
|
|
iinfo->i_checkpoint = 1;
|
|
iinfo->i_extraPerms = FE_PERM_U_CHATTR;
|
|
udf_update_extra_perms(inode, mode);
|
|
|
|
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
|
|
iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
|
|
else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
|
|
iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
|
|
else
|
|
iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
|
|
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
|
|
iinfo->i_crtime = inode->i_mtime;
|
|
if (unlikely(insert_inode_locked(inode) < 0)) {
|
|
make_bad_inode(inode);
|
|
iput(inode);
|
|
return ERR_PTR(-EIO);
|
|
}
|
|
mark_inode_dirty(inode);
|
|
|
|
return inode;
|
|
}
|