summaryrefslogtreecommitdiff
path: root/fs/udf
Commit message (Collapse)AuthorAgeFilesLines
* udf: use wrapper i_blocksize() in udf_discard_prealloc()Yangtao Li2023-03-131-2/+2
| | | | | | | | Convert to use i_blocksize() for readability. Signed-off-by: Yangtao Li <frank.li@vivo.com> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20230310030821.66090-2-frank.li@vivo.com>
* udf: Use folios in udf_adinicb_writepage()Matthew Wilcox (Oracle)2023-03-081-5/+5
| | | | | | | | Make udf_adinicb_writepage() fully converted to using the passed folio instead of converting it to the page. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Warn if block mapping is done for in-ICB filesJan Kara2023-03-061-0/+3
| | | | | | | | | Now that address space operations are merge dfor in-ICB and normal files, it is more likely some code mistakenly tries to map blocks for in-ICB files. WARN and return error instead of silently returning garbage. Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Fix reading of in-ICB filesJan Kara2023-03-061-0/+9
| | | | | | | | | | | | After merging address space operations of normal and in-ICB files, readahead could get called for in-ICB files which resulted in udf_get_block() being called for these files. udf_get_block() is not prepared to be called for in-ICB files and ends up returning garbage results as it interprets file data as extent list. Fix the problem by skipping readahead for in-ICB files. Fixes: 37a8a39f7ad3 ("udf: Switch to single address_space_operations") Signed-off-by: Jan Kara <jack@suse.cz>
* udf: Fix lost writes in udf_adinicb_writepage()Jan Kara2023-03-061-1/+1
| | | | | | | | | | | The patch converting udf_adinicb_writepage() to avoid manually kmapping the page used memcpy_to_page() however that copies in the wrong direction (effectively overwriting file data with the old contents). What we should be using is memcpy_from_page() to copy data from the page into the inode and then mark inode dirty to store the data. Fixes: 5cfc45321a6d ("udf: Convert udf_adinicb_writepage() to memcpy_to_page()") Signed-off-by: Jan Kara <jack@suse.cz>
* Merge tag 'mm-stable-2023-02-20-13-37' of ↵Linus Torvalds2023-02-231-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull MM updates from Andrew Morton: - Daniel Verkamp has contributed a memfd series ("mm/memfd: add F_SEAL_EXEC") which permits the setting of the memfd execute bit at memfd creation time, with the option of sealing the state of the X bit. - Peter Xu adds a patch series ("mm/hugetlb: Make huge_pte_offset() thread-safe for pmd unshare") which addresses a rare race condition related to PMD unsharing. - Several folioification patch serieses from Matthew Wilcox, Vishal Moola, Sidhartha Kumar and Lorenzo Stoakes - Johannes Weiner has a series ("mm: push down lock_page_memcg()") which does perform some memcg maintenance and cleanup work. - SeongJae Park has added DAMOS filtering to DAMON, with the series "mm/damon/core: implement damos filter". These filters provide users with finer-grained control over DAMOS's actions. SeongJae has also done some DAMON cleanup work. - Kairui Song adds a series ("Clean up and fixes for swap"). - Vernon Yang contributed the series "Clean up and refinement for maple tree". - Yu Zhao has contributed the "mm: multi-gen LRU: memcg LRU" series. It adds to MGLRU an LRU of memcgs, to improve the scalability of global reclaim. - David Hildenbrand has added some userfaultfd cleanup work in the series "mm: uffd-wp + change_protection() cleanups". - Christoph Hellwig has removed the generic_writepages() library function in the series "remove generic_writepages". - Baolin Wang has performed some maintenance on the compaction code in his series "Some small improvements for compaction". - Sidhartha Kumar is doing some maintenance work on struct page in his series "Get rid of tail page fields". - David Hildenbrand contributed some cleanup, bugfixing and generalization of pte management and of pte debugging in his series "mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE on all architectures with swap PTEs". - Mel Gorman and Neil Brown have removed the __GFP_ATOMIC allocation flag in the series "Discard __GFP_ATOMIC". - Sergey Senozhatsky has improved zsmalloc's memory utilization with his series "zsmalloc: make zspage chain size configurable". - Joey Gouly has added prctl() support for prohibiting the creation of writeable+executable mappings. The previous BPF-based approach had shortcomings. See "mm: In-kernel support for memory-deny-write-execute (MDWE)". - Waiman Long did some kmemleak cleanup and bugfixing in the series "mm/kmemleak: Simplify kmemleak_cond_resched() & fix UAF". - T.J. Alumbaugh has contributed some MGLRU cleanup work in his series "mm: multi-gen LRU: improve". - Jiaqi Yan has provided some enhancements to our memory error statistics reporting, mainly by presenting the statistics on a per-node basis. See the series "Introduce per NUMA node memory error statistics". - Mel Gorman has a second and hopefully final shot at fixing a CPU-hog regression in compaction via his series "Fix excessive CPU usage during compaction". - Christoph Hellwig does some vmalloc maintenance work in the series "cleanup vfree and vunmap". - Christoph Hellwig has removed block_device_operations.rw_page() in ths series "remove ->rw_page". - We get some maple_tree improvements and cleanups in Liam Howlett's series "VMA tree type safety and remove __vma_adjust()". - Suren Baghdasaryan has done some work on the maintainability of our vm_flags handling in the series "introduce vm_flags modifier functions". - Some pagemap cleanup and generalization work in Mike Rapoport's series "mm, arch: add generic implementation of pfn_valid() for FLATMEM" and "fixups for generic implementation of pfn_valid()" - Baoquan He has done some work to make /proc/vmallocinfo and /proc/kcore better represent the real state of things in his series "mm/vmalloc.c: allow vread() to read out vm_map_ram areas". - Jason Gunthorpe rationalized the GUP system's interface to the rest of the kernel in the series "Simplify the external interface for GUP". - SeongJae Park wishes to migrate people from DAMON's debugfs interface over to its sysfs interface. To support this, we'll temporarily be printing warnings when people use the debugfs interface. See the series "mm/damon: deprecate DAMON debugfs interface". - Andrey Konovalov provided the accurately named "lib/stackdepot: fixes and clean-ups" series. - Huang Ying has provided a dramatic reduction in migration's TLB flush IPI rates with the series "migrate_pages(): batch TLB flushing". - Arnd Bergmann has some objtool fixups in "objtool warning fixes". * tag 'mm-stable-2023-02-20-13-37' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (505 commits) include/linux/migrate.h: remove unneeded externs mm/memory_hotplug: cleanup return value handing in do_migrate_range() mm/uffd: fix comment in handling pte markers mm: change to return bool for isolate_movable_page() mm: hugetlb: change to return bool for isolate_hugetlb() mm: change to return bool for isolate_lru_page() mm: change to return bool for folio_isolate_lru() objtool: add UACCESS exceptions for __tsan_volatile_read/write kmsan: disable ftrace in kmsan core code kasan: mark addr_has_metadata __always_inline mm: memcontrol: rename memcg_kmem_enabled() sh: initialize max_mapnr m68k/nommu: add missing definition of ARCH_PFN_OFFSET mm: percpu: fix incorrect size in pcpu_obj_full_size() maple_tree: reduce stack usage with gcc-9 and earlier mm: page_alloc: call panic() when memoryless node allocation fails mm: multi-gen LRU: avoid futile retries migrate_pages: move THP/hugetlb migration support check to simplify code migrate_pages: batch flushing TLB migrate_pages: share more code between _unmap and _move ...
* \ Merge tag 'for-6.3/dio-2023-02-16' of git://git.kernel.dk/linuxLinus Torvalds2023-02-201-0/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull legacy dio update from Jens Axboe: "We only have a few file systems that use the old dio code, make them select it rather than build it unconditionally" * tag 'for-6.3/dio-2023-02-16' of git://git.kernel.dk/linux: fs: build the legacy direct I/O code conditionally fs: move sb_init_dio_done_wq out of direct-io.c
| * | fs: build the legacy direct I/O code conditionallyChristoph Hellwig2023-01-261-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Add a new LEGACY_DIRECT_IO config symbol that is only selected by the file systems that still use the legacy blockdev_direct_IO code, so that kernels without support for those file systems don't need to build the code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20230125065839.191256-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
* | Merge tag 'fixes_for_v6.3-rc1' of ↵Linus Torvalds2023-02-2016-1535/+1335
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ...
| * | udf: Avoid directory type conversion failure due to ENOMEMJan Kara2023-02-091-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When converting directory from in-ICB to normal format, the last iteration through the directory fixing up directory enteries can fail due to ENOMEM. We do not expect this iteration to fail since the directory is already verified to be correct and it is difficult to undo the conversion at this point. So just use GFP_NOFAIL to make sure the small allocation cannot fail. Reported-by: syzbot+111eaa994ff74f8d440f@syzkaller.appspotmail.com Fixes: 0aba4860b0d0 ("udf: Allocate name buffer in directory iterator on heap") Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Use unsigned variables for size calculationsKees Cook2023-02-071-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid confusing the compiler about possible negative sizes, switch various size variables that can never be negative from int to u32. Seen with GCC 13: ../fs/udf/directory.c: In function 'udf_copy_fi': ../include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' pointer overflow between offset 80 and size [-2147483648, -1] [-Warray-bounds=] 57 | #define __underlying_memcpy __builtin_memcpy | ^ ... ../fs/udf/directory.c:102:9: note: in expansion of macro 'memcpy' 102 | memcpy(&iter->fi, iter->bh[0]->b_data + off, len); | ^~~~~~ Cc: Jan Kara <jack@suse.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20230204183427.never.856-kees@kernel.org>
| * | udf: remove reporting loc in debug outputTom Rix2023-02-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang build fails with fs/udf/partition.c:86:28: error: variable 'loc' is uninitialized when used here [-Werror,-Wuninitialized] sb, block, partition, loc, index); ^~~ loc is now only known when bh is valid. So remove reporting loc in debug output. Fixes: 4215db46d538 ("udf: Use udf_bread() in udf_get_pblock_virt15()") Reported-by: kernel test robot <lkp@intel.com> Reported-by: "kernelci.org bot" <bot@kernelci.org> Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Check consistency of Space Bitmap DescriptorVladislav Efanov2023-02-071-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bits, which are related to Bitmap Descriptor logical blocks, are not reset when buffer headers are allocated for them. As the result, these logical blocks can be treated as free and be used for other blocks.This can cause usage of one buffer header for several types of data. UDF issues WARNING in this situation: WARNING: CPU: 0 PID: 2703 at fs/udf/inode.c:2014 __udf_add_aext+0x685/0x7d0 fs/udf/inode.c:2014 RIP: 0010:__udf_add_aext+0x685/0x7d0 fs/udf/inode.c:2014 Call Trace: udf_setup_indirect_aext+0x573/0x880 fs/udf/inode.c:1980 udf_add_aext+0x208/0x2e0 fs/udf/inode.c:2067 udf_insert_aext fs/udf/inode.c:2233 [inline] udf_update_extents fs/udf/inode.c:1181 [inline] inode_getblk+0x1981/0x3b70 fs/udf/inode.c:885 Found by Linux Verification Center (linuxtesting.org) with syzkaller. [JK: Somewhat cleaned up the boundary checks] Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Fix file counting in LVIDJan Kara2023-01-262-28/+25
| | | | | | | | | | | | | | | | | | | | | | | | numFiles entry in LVID should actually contain number for non-dir file entries, not the number of non-dir inodes. Move the counting from inode allocation / deallocation into directory entry handling functions. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Limit file size to 4TBJan Kara2023-01-261-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UDF disk format supports in principle file sizes up to 1<<64-1. However the file space (including holes) is described by a linked list of extents, each of which can have at most 1GB. Thus the creation and handling of extents gets unusably slow beyond certain point. Limit the file size to 4TB to avoid locking up the kernel too easily. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Don't return bh from udf_expand_dir_adinicb()Jan Kara2023-01-261-20/+13
| | | | | | | | | | | | | | | | | | | | | Nobody uses the bh returned from udf_expand_dir_adinicb(). Don't return it. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert udf_expand_file_adinicb() to avoid kmap_atomic()Jan Kara2023-01-261-14/+4
| | | | | | | | | | | | | | | | | | | | | | | | Remove the last two remaining kmap_atomic() uses in UDF in udf_expand_file_adinicb(). The first use can be actually conveniently replaced with udf_adinicb_readpage(), the second with memcpy_to_page(). Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert udf_adinicb_writepage() to memcpy_to_page()Jan Kara2023-01-261-6/+2
| | | | | | | | | | | | | | | | | | | | | Instead of mapping the page manually with kmap() atomic, use helper memcpy_to_page(). Also delete the pointless SetPageUptodate() call. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Switch udf_adinicb_readpage() to kmap_local_page()Jan Kara2023-01-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using kmap_atomic() use kmap_local_page() in udf_adinicb_readpage(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Move udf_adinicb_readpage() to inode.cJan Kara2023-01-263-20/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | udf_adinicb_readpage() is only called from aops functions, move it to the same file as its callers and also drop the stale comment - invalidate_lock is protecting us against races with truncate. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Mark aops implementation staticJan Kara2023-01-262-18/+10
| | | | | | | | | | | | | | | | | | | | | | | | Mark functions implementing aops static since they are not needed outside of inode.c anymore. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Switch to single address_space_operationsJan Kara2023-01-264-26/+3
| | | | | | | | | | | | | | | | | | | | | | | | Now that udf_aops and udf_adiniicb_aops are functionally identical, just drop udf_adiniicb_aops. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Add handling of in-ICB files to udf_bmap()Jan Kara2023-01-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Add detection of in-ICB files to udf_bmap() and return error in that case. This will allow us o use single address_space_operations in UDF. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert all file types to use udf_write_end()Jan Kara2023-01-263-16/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, create udf_write_end() function that is able to handle both normal and in-ICB files. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert in-ICB files to use udf_write_begin()Jan Kara2023-01-263-25/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make in-ICB files use udf_write_begin(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert in-ICB files to use udf_direct_IO()Jan Kara2023-01-263-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make in-ICB files use udf_direct_IO(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert in-ICB files to use udf_writepages()Jan Kara2023-01-263-23/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make in-ICB files use udf_writepages(). Reported-by: syzbot+c27475eb921c46bbdc62@syzkaller.appspotmail.com Reported-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Unify .read_folio for normal and in-ICB filesJan Kara2023-01-263-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Switching address_space_operations while a file is used is difficult to do in a race-free way. To be able to use single address_space_operations in UDF, make udf_read_folio() handle both normal and in-ICB files. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Fix off-by-one error when discarding preallocationJan Kara2023-01-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The condition determining whether the preallocation can be used had an off-by-one error so we didn't discard preallocation when new allocation was just following it. This can then confuse code in inode_getblk(). CC: stable@vger.kernel.org Fixes: 16d055656814 ("udf: Discard preallocation before extending file with a hole") Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Fix file corruption when appending just after end of preallocated extentJan Kara2023-01-261-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we append new block just after the end of preallocated extent, the code in inode_getblk() wrongly determined we're going to use the preallocated extent which resulted in adding block into a wrong logical offset in the file. Sequence like this manifests it: xfs_io -f -c "pwrite 0x2cacf 0xd122" -c "truncate 0x2dd6f" \ -c "pwrite 0x27fd9 0x69a9" -c "pwrite 0x32981 0x7244" <file> The code that determined the use of preallocated extent is actually stale because udf_do_extend_file() does not create preallocation anymore so after calling that function we are sure there's no usable preallocation. Just remove the faulty condition. CC: stable@vger.kernel.org Fixes: 16d055656814 ("udf: Discard preallocation before extending file with a hole") Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Do not allocate blocks on page writebackJan Kara2023-01-261-12/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now when we allocate blocks on write page fault there should be no block allocation happening on page writeback. So just ignore the 'create' flag passed to udf_get_block(). Note that we can spot dirty buffers without underlying blocks allocated in writeback when we race with expanding truncate. However in that case these buffers do not contain valid data so we can safely ignore them and we would just create ourselves problem when to trim the tail extent. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Allocate blocks on write page faultJan Kara2023-01-263-2/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently if file with holes is mapped, udf allocates blocks for dirtied pages during page writeback. This however creates problems when to truncate final extent to proper size and currently we leave the last extent untruncated which violates UDF standard. So allocate blocks on write page fault instead. In that case the last extent gets truncated the file is closed and everything is happy. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Protect truncate and file type conversion with invalidate_lockJan Kara2023-01-262-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Protect truncate and file type conversion in udf_file_write_iter() with invalidate lock. That will allow us to serialize these paths with page faults so that the page fault can determine the file type in a racefree way. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Simplify error handling in udf_file_write_iter()Jan Kara2023-01-261-7/+3
| | | | | | | | | | | | | | | | | | | | | When udf_expand_file_adinicb() fails, we can now use the standard exit path instead of implementing our own. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Push i_data_sem locking into udf_extend_file()Jan Kara2023-01-261-5/+4
| | | | | | | | | | | | | | | | | | | | | Push i_data_sem locking into udf_extend_file(). It somewhat simplifies the code around it. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Push i_data_sem locking into udf_expand_file_adinicb()Jan Kara2023-01-262-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | The checks we do in udf_setsize() and udf_file_write_iter() are safe to do only with i_rwsem locked as it stabilizes both file type and file size. Hence we don't need to lock i_data_sem before we enter udf_expand_file_adinicb() which simplifies the locking somewhat. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Protect rename against modification of moved directoryJan Kara2023-01-261-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we are renaming a directory to a different directory, we need to update '..' entry in the moved directory. However nothing prevents moved directory from being modified and even converted from the in-ICB format to the normal format which results in a crash. Fix the problem by locking the moved directory. Reported-by: syzbot+aebf90eea2671c43112a@syzkaller.appspotmail.com Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Fold udf_getblk() into udf_bread()Jan Kara2023-01-261-27/+20
| | | | | | | | | | | | | | | | | | udf_getblk() has a single call site. Fold it there. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Use udf_map_block() in udf_getblk()Jan Kara2023-01-261-8/+9
| | | | | | | | | | | | | | | | | | Use the new function udf_map_block() in udf_getblk(). Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Add flag to disable block preallocationJan Kara2023-01-261-6/+11
| | | | | | | | | | | | | | | | | | | | | In some cases we don't want to create block preallocation when allocating blocks. Add a flag to udf_map_rq controlling the behavior. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Pass mapping request into inode_getblk()Jan Kara2023-01-261-33/+23
| | | | | | | | | | | | | | | | | | | | | Pass struct udf_map_rq into inode_getblk() instead of unfolding it and the putting the results back. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Fold udf_block_map() into udf_map_block()Jan Kara2023-01-262-25/+14
| | | | | | | | | | | | | | | | | | udf_block_map() has now only a single caller. Fold it there. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Convert udf_symlink_filler() to use udf_bread()Jan Kara2023-01-261-7/+4
| | | | | | | | | | | | | | | | | | | | | Convert udf_symlink_filler() to use udf_bread() instead of mapping and reading buffer head manually. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Do not call udf_block_map() on ICB filesJan Kara2023-01-261-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently udf_symlink_filler() called udf_block_map() even on files which have data stored inside the ICB. This is invalid as we cannot map blocks for such files (although so far the error got silently ignored). The call happened because we could not call block mapping function once we've acquired i_data_sem and determined whether the file has data stored in the ICB. For symlinks the situation is luckily simple as they get never modified so file type never changes once it is set. Hence we can check the file type even without i_data_sem. Just drop the i_data_sem locking and move block mapping to where it is needed. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Use udf_bread() in udf_load_vat()Jan Kara2023-01-261-5/+8
| | | | | | | | | | | | | | | | | | | | | Use udf_bread() instead of mapping and loadign buffer head manually in udf_load_vat(). Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Use udf_bread() in udf_get_pblock_virt15()Jan Kara2023-01-261-3/+2
| | | | | | | | | | | | | | | | | | | | | Use udf_bread() instead of mapping and reading buffer head manually in udf_get_pblock_virt15(). Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Factor out block mapping into udf_map_block()Jan Kara2023-01-262-22/+49
| | | | | | | | | | | | | | | | | | | | | | | | Create new block mapping function udf_map_block() that takes new udf_map_rq structure describing mapping request. We will convert other places to use this function for block mapping. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Move incrementing of goal block directly into inode_getblk()Jan Kara2023-01-261-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | inode_getblk() sets goal block for the next allocation to the currently allocated block. This is obviously one less than what the goal block should be which we fixup in udf_get_block(). Just set the right goal block directly in inode_getblk(). Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Drop VARCONV supportJan Kara2023-01-269-84/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UDF was supporting a strange mode where the media was containing 7 blocks of unknown data for every 32 blocks of the filesystem. I have yet to see the media that would need such conversion (maybe it comes from packet writing times) and the conversions have been inconsistent in the code. In particular any write will write to a wrong block and corrupt the media. This is an indication and no user actually needs this so let's just drop the support instead of trying to fix it. Signed-off-by: Jan Kara <jack@suse.cz>
| * | udf: Unify types in anchor block detectionJan Kara2023-01-263-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When detecting last recorded block and from it derived anchor block position, we were mixing unsigned long, u32, and sector_t types. Since udf supports only 32-bit block numbers this is harmless but sometimes makes things awkward. Convert everything to udf_pblk_t and also handle the situation when block device size would not fit into udf_pblk_t. Signed-off-by: Jan Kara <jack@suse.cz>