tree: https://github.com/ceph/ceph-client.git testing head: 6dc7235ee916b768b31afa12ab507874bd278573 commit: 85fc162016ac8d19e28877a15f55c0fa4b47713b [6/8] ceph: Make ceph_netfs_issue_op() handle inlined data config: mips-randconfig-r014-20220209 (https://download.01.org/0day-ci/archive/20220210/202202102053.7C17duIV-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project aa845d7a245d85c441d0bd44fc7b6c3be8f3de8d) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install mips cross compiling tool for clang build # apt-get install binutils-mips-linux-gnu # https://github.com/ceph/ceph-client/commit/85fc162016ac8d19e28877a15f55c0fa4b47713b git remote add ceph-client https://github.com/ceph/ceph-client.git git fetch --no-tags ceph-client testing git checkout 85fc162016ac8d19e28877a15f55c0fa4b47713b # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash fs/ceph/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): >> fs/ceph/addr.c:788:12: warning: stack frame size (2352) exceeds limit (2048) in 'ceph_writepages_start' static int ceph_writepages_start(struct address_space ^ fatal error: error in backend: Nested variants found in inline asm string: ' .set push .set mips64r6 .if ( 0x00 ) != -1)) 0x00 ) != -1)) : ($( static struct ftrace_branch_data __attribute__((__aligned__(4))) __attribute__((__section__("_ftrace_branch"))) __if_trace = $( .func = __func__, .file = "arch/mips/include/asm/bitops.h", .line = 190, $); 0x00 ) != -1)) : $))) ) && ( 0 ); .set push; .set mips64r6; .rept 1; sync 0x00; .endr; .set pop; .else; ; .endif 1: lld $0, $2 or $1, $0, $3 scd $1, $2 beqzc $1, 1b .set pop ' PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: clang -Wp,-MMD,fs/ceph/.addr.o.d -nostdinc -Iarch/mips/include -I./arch/mips/include/generated -Iinclude -I./include -Iarch/mips/include/uapi -I./arch/mips/include/generated/uapi -Iinclude/uapi -I./include/generated/uapi -include include/linux/compiler-version.h -include include/linux/kconfig.h -include include/linux/compiler_types.h -D__KERNEL__ -DVMLINUX_LOAD_ADDRESS=0xffffffff84000000 -DLINKER_LOAD_ADDRESS=0xffffffff84000000 -DDATAOFFSET=0 -Qunused-arguments -fmacro-prefix-map== -DKBUILD_EXTRA_WARN1 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 --target=mips64-linux -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -mabi=64 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float -ffreestanding -EB -fno-stack-check -march=mips64r6 -Wa,--trap -DTOOLCHAIN_SUPPORTS_VIRT -Iarch/mips/include/asm/mach-generic -Iarch/mips/include/asm/mach-generic -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fno-stack-protector -Wimplicit-fallthrough -Wno-gnu -mno-global-merge -Wno-unused-but-set-variable -Wno-unused-const-variable -ftrivial-auto-var-init=pattern -fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -fno-strict-overflow -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -Wextra -Wunused -Wno-unused-parameter -Wmissing-declarations -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition -Wmissing-include-dirs -Wunused-but-set-variable -Wunused-const-variable -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits -fsanitize=unreachable -fsanitize=enum -I fs/ceph -I ./fs/ceph -DMODULE -mlong-calls -DKBUILD_BASENAME="addr" -DKBUILD_MODNAME="ceph" -D__KBUILD_MODNAME=kmod_ceph -c -o fs/ceph/addr.o fs/ceph/addr.c 1. parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module 'fs/ceph/addr.c'. 4. Running pass 'Mips Assembly Printer' on function '@ceph_writepages_start' #0 0x000055a535e1f68f Signals.cpp:0:0 #1 0x000055a535e1d56c llvm::sys::CleanupOnSignal(unsigned long) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x347456c) #2 0x000055a535d5d9e7 llvm::CrashRecoveryContext::HandleExit(int) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x33b49e7) #3 0x000055a535e15c1e llvm::sys::Process::Exit(int, bool) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x346cc1e) #4 0x000055a533a508bb (/opt/cross/clang-aa845d7a24/bin/clang-15+0x10a78bb) #5 0x000055a535d6449c llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x33bb49c) #6 0x000055a536a56000 llvm::AsmPrinter::emitInlineAsm(llvm::MachineInstr const (/opt/cross/clang-aa845d7a24/bin/clang-15+0x40ad000) #7 0x000055a536a51f34 llvm::AsmPrinter::emitFunctionBody() (/opt/cross/clang-aa845d7a24/bin/clang-15+0x40a8f34) #8 0x000055a5344bb1e7 llvm::MipsAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x1b121e7) #9 0x000055a535170a3d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.53) MachineFunctionPass.cpp:0:0 #10 0x000055a5355b1757 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x2c08757) #11 0x000055a5355b18d1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x2c088d1) #12 0x000055a5355b244f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x2c0944f) #13 0x000055a536137917 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, clang::BackendAction, std::unique_ptr >) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x378e917) #14 0x000055a536d6f063 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x43c6063) #15 0x000055a537845629 clang::ParseAST(clang::Sema&, bool, bool) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x4e9c629) #16 0x000055a536d6de9f clang::CodeGenAction::ExecuteAction() (/opt/cross/clang-aa845d7a24/bin/clang-15+0x43c4e9f) #17 0x000055a53676ac81 clang::FrontendAction::Execute() (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3dc1c81) #18 0x000055a536701b0a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3d58b0a) #19 0x000055a53682f59b (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3e8659b) #20 0x000055a533a51e6c cc1_main(llvm::ArrayRef::callback_fn >, std::__cxx11::basic_string, std::allocator const::'lambda'()>(long) Job.cpp:0:0 #23 0x000055a535d5d8a3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x33b48a3) #24 0x000055a53659a05e clang::driver::CC1Command::Execute(llvm::ArrayRef >, std::__cxx11::basic_string, std::allocator const (.part.216) Job.cpp:0:0 #25 0x000055a53656ec57 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3bc5c57) #26 0x000055a53656f637 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl&) const (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3bc6637) #27 0x000055a536578cc9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3bcfcc9) #28 0x000055a53397738f main (/opt/cross/clang-aa845d7a24/bin/clang-15+0xfce38f) #29 0x00007fe35f12cd0a __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26d0a) #30 0x000055a533a4e65a _start (/opt/cross/clang-aa845d7a24/bin/clang-15+0x10a565a) clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation) clang version 15.0.0 (git://gitmirror/llvm_project aa845d7a245d85c441d0bd44fc7b6c3be8f3de8d) Target: mips64-unknown-linux Thread model: posix InstalledDir: /opt/cross/clang-aa845d7a24/bin clang-15: note: diagnostic msg: Makefile arch fs include kernel nr_bisected scripts source usr -- >> fs/ceph/addr.c:788:12: warning: stack frame size (2352) exceeds limit (2048) in 'ceph_writepages_start' static int ceph_writepages_start(struct address_space ^ fatal error: error in backend: Nested variants found in inline asm string: ' .set push .set mips64r6 .if ( 0x00 ) != -1)) 0x00 ) != -1)) : ($( static struct ftrace_branch_data __attribute__((__aligned__(4))) __attribute__((__section__("_ftrace_branch"))) __if_trace = $( .func = __func__, .file = "arch/mips/include/asm/bitops.h", .line = 190, $); 0x00 ) != -1)) : $))) ) && ( 0 ); .set push; .set mips64r6; .rept 1; sync 0x00; .endr; .set pop; .else; ; .endif 1: lld $0, $2 or $1, $0, $3 scd $1, $2 beqzc $1, 1b .set pop ' PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: clang -Wp,-MMD,fs/ceph/.addr.o.d -nostdinc -Iarch/mips/include -I./arch/mips/include/generated -Iinclude -I./include -Iarch/mips/include/uapi -I./arch/mips/include/generated/uapi -Iinclude/uapi -I./include/generated/uapi -include include/linux/compiler-version.h -include include/linux/kconfig.h -include include/linux/compiler_types.h -D__KERNEL__ -DVMLINUX_LOAD_ADDRESS=0xffffffff84000000 -DLINKER_LOAD_ADDRESS=0xffffffff84000000 -DDATAOFFSET=0 -Qunused-arguments -fmacro-prefix-map== -DKBUILD_EXTRA_WARN1 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 --target=mips64-linux -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -mabi=64 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float -ffreestanding -EB -fno-stack-check -march=mips64r6 -Wa,--trap -DTOOLCHAIN_SUPPORTS_VIRT -Iarch/mips/include/asm/mach-generic -Iarch/mips/include/asm/mach-generic -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fno-stack-protector -Wimplicit-fallthrough -Wno-gnu -mno-global-merge -Wno-unused-but-set-variable -Wno-unused-const-variable -ftrivial-auto-var-init=pattern -fno-stack-clash-protection -pg -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -fno-strict-overflow -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -Wextra -Wunused -Wno-unused-parameter -Wmissing-declarations -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition -Wmissing-include-dirs -Wunused-but-set-variable -Wunused-const-variable -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits -fsanitize=unreachable -fsanitize=enum -DMODULE -mlong-calls -DKBUILD_BASENAME="addr" -DKBUILD_MODNAME="ceph" -D__KBUILD_MODNAME=kmod_ceph -c -o fs/ceph/addr.o fs/ceph/addr.c 1. parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module 'fs/ceph/addr.c'. 4. Running pass 'Mips Assembly Printer' on function '@ceph_writepages_start' #0 0x0000562358d5368f Signals.cpp:0:0 #1 0x0000562358d5156c llvm::sys::CleanupOnSignal(unsigned long) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x347456c) #2 0x0000562358c919e7 llvm::CrashRecoveryContext::HandleExit(int) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x33b49e7) #3 0x0000562358d49c1e llvm::sys::Process::Exit(int, bool) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x346cc1e) #4 0x00005623569848bb (/opt/cross/clang-aa845d7a24/bin/clang-15+0x10a78bb) #5 0x0000562358c9849c llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x33bb49c) #6 0x000056235998a000 llvm::AsmPrinter::emitInlineAsm(llvm::MachineInstr const (/opt/cross/clang-aa845d7a24/bin/clang-15+0x40ad000) #7 0x0000562359985f34 llvm::AsmPrinter::emitFunctionBody() (/opt/cross/clang-aa845d7a24/bin/clang-15+0x40a8f34) #8 0x00005623573ef1e7 llvm::MipsAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x1b121e7) #9 0x00005623580a4a3d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.53) MachineFunctionPass.cpp:0:0 #10 0x00005623584e5757 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x2c08757) #11 0x00005623584e58d1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x2c088d1) #12 0x00005623584e644f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x2c0944f) #13 0x000056235906b917 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, clang::BackendAction, std::unique_ptr >) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x378e917) #14 0x0000562359ca3063 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x43c6063) #15 0x000056235a779629 clang::ParseAST(clang::Sema&, bool, bool) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x4e9c629) #16 0x0000562359ca1e9f clang::CodeGenAction::ExecuteAction() (/opt/cross/clang-aa845d7a24/bin/clang-15+0x43c4e9f) #17 0x000056235969ec81 clang::FrontendAction::Execute() (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3dc1c81) #18 0x0000562359635b0a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3d58b0a) #19 0x000056235976359b (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3e8659b) #20 0x0000562356985e6c cc1_main(llvm::ArrayRef::callback_fn >, std::__cxx11::basic_string, std::allocator const::'lambda'()>(long) Job.cpp:0:0 #23 0x0000562358c918a3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x33b48a3) #24 0x00005623594ce05e clang::driver::CC1Command::Execute(llvm::ArrayRef >, std::__cxx11::basic_string, std::allocator const (.part.216) Job.cpp:0:0 #25 0x00005623594a2c57 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3bc5c57) #26 0x00005623594a3637 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl&) const (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3bc6637) #27 0x00005623594accc9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl&) (/opt/cross/clang-aa845d7a24/bin/clang-15+0x3bcfcc9) #28 0x00005623568ab38f main (/opt/cross/clang-aa845d7a24/bin/clang-15+0xfce38f) #29 0x00007f845ced9d0a __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26d0a) #30 0x000056235698265a _start (/opt/cross/clang-aa845d7a24/bin/clang-15+0x10a565a) clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation) clang version 15.0.0 (git://gitmirror/llvm_project aa845d7a245d85c441d0bd44fc7b6c3be8f3de8d) Target: mips64-unknown-linux Thread model: posix InstalledDir: /opt/cross/clang-aa845d7a24/bin clang-15: note: diagnostic msg: Makefile arch fs include kernel nr_bisected scripts source usr vim +/ceph_writepages_start +788 fs/ceph/addr.c 1d3576fd10f0d7 Sage Weil 2009-10-06 784 1d3576fd10f0d7 Sage Weil 2009-10-06 785 /* 1d3576fd10f0d7 Sage Weil 2009-10-06 786 * initiate async writeback 1d3576fd10f0d7 Sage Weil 2009-10-06 787 */ 1d3576fd10f0d7 Sage Weil 2009-10-06 @788 static int ceph_writepages_start(struct address_space *mapping, 1d3576fd10f0d7 Sage Weil 2009-10-06 789 struct writeback_control *wbc) 1d3576fd10f0d7 Sage Weil 2009-10-06 790 { 1d3576fd10f0d7 Sage Weil 2009-10-06 791 struct inode *inode = mapping->host; 1d3576fd10f0d7 Sage Weil 2009-10-06 792 struct ceph_inode_info *ci = ceph_inode(inode); fc2744aa12da71 Yan, Zheng 2013-05-31 793 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); fc2744aa12da71 Yan, Zheng 2013-05-31 794 struct ceph_vino vino = ceph_vino(inode); 2a2d927e35dd8d Yan, Zheng 2017-09-01 795 pgoff_t index, start_index, end = -1; 80e755fedebc8d Sage Weil 2010-03-31 796 struct ceph_snap_context *snapc = NULL, *last_snapc = NULL, *pgsnapc; 1d3576fd10f0d7 Sage Weil 2009-10-06 797 struct pagevec pvec; 1d3576fd10f0d7 Sage Weil 2009-10-06 798 int rc = 0; 93407472a21b82 Fabian Frederick 2017-02-27 799 unsigned int wsize = i_blocksize(inode); 1d3576fd10f0d7 Sage Weil 2009-10-06 800 struct ceph_osd_request *req = NULL; 1f934b00e90752 Yan, Zheng 2017-08-30 801 struct ceph_writeback_ctl ceph_wbc; 590e9d9861f5f2 Yan, Zheng 2017-09-03 802 bool should_loop, range_whole = false; af9cc401ce7452 Yan, Zheng 2018-03-04 803 bool done = false; 1702e79734104d Jeff Layton 2021-12-07 804 bool caching = ceph_is_cache_enabled(inode); 1d3576fd10f0d7 Sage Weil 2009-10-06 805 3fb99d483e614b Yanhu Cao 2017-07-21 806 dout("writepages_start %p (mode=%s)\n", inode, 1d3576fd10f0d7 Sage Weil 2009-10-06 807 wbc->sync_mode == WB_SYNC_NONE ? "NONE" : 1d3576fd10f0d7 Sage Weil 2009-10-06 808 (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD")); 1d3576fd10f0d7 Sage Weil 2009-10-06 809 5d6451b1489ad1 Jeff Layton 2021-08-31 810 if (ceph_inode_is_shutdown(inode)) { 6c93df5db628e7 Yan, Zheng 2016-04-15 811 if (ci->i_wrbuffer_ref > 0) { 6c93df5db628e7 Yan, Zheng 2016-04-15 812 pr_warn_ratelimited( 6c93df5db628e7 Yan, Zheng 2016-04-15 813 "writepage_start %p %lld forced umount\n", 6c93df5db628e7 Yan, Zheng 2016-04-15 814 inode, ceph_ino(inode)); 6c93df5db628e7 Yan, Zheng 2016-04-15 815 } a341d4df87487a Yan, Zheng 2015-07-01 816 mapping_set_error(mapping, -EIO); 1d3576fd10f0d7 Sage Weil 2009-10-06 817 return -EIO; /* we're in a forced umount, don't write! */ 1d3576fd10f0d7 Sage Weil 2009-10-06 818 } 95cca2b44e54b0 Yan, Zheng 2017-07-11 819 if (fsc->mount_options->wsize < wsize) 3d14c5d2b6e15c Yehuda Sadeh 2010-04-06 820 wsize = fsc->mount_options->wsize; 1d3576fd10f0d7 Sage Weil 2009-10-06 821 8667982014d604 Mel Gorman 2017-11-15 822 pagevec_init(&pvec); 1d3576fd10f0d7 Sage Weil 2009-10-06 823 590e9d9861f5f2 Yan, Zheng 2017-09-03 824 start_index = wbc->range_cyclic ? mapping->writeback_index : 0; 590e9d9861f5f2 Yan, Zheng 2017-09-03 825 index = start_index; 1d3576fd10f0d7 Sage Weil 2009-10-06 826 1d3576fd10f0d7 Sage Weil 2009-10-06 827 retry: 1d3576fd10f0d7 Sage Weil 2009-10-06 828 /* find oldest snap context with dirty data */ 05455e1177f768 Yan, Zheng 2017-09-02 829 snapc = get_oldest_context(inode, &ceph_wbc, NULL); 1d3576fd10f0d7 Sage Weil 2009-10-06 830 if (!snapc) { 1d3576fd10f0d7 Sage Weil 2009-10-06 831 /* hmm, why does writepages get called when there 1d3576fd10f0d7 Sage Weil 2009-10-06 832 is no dirty data? */ 1d3576fd10f0d7 Sage Weil 2009-10-06 833 dout(" no snap context with dirty data?\n"); 1d3576fd10f0d7 Sage Weil 2009-10-06 834 goto out; 1d3576fd10f0d7 Sage Weil 2009-10-06 835 } 1d3576fd10f0d7 Sage Weil 2009-10-06 836 dout(" oldest snapc is %p seq %lld (%d snaps)\n", 1d3576fd10f0d7 Sage Weil 2009-10-06 837 snapc, snapc->seq, snapc->num_snaps); fc2744aa12da71 Yan, Zheng 2013-05-31 838 2a2d927e35dd8d Yan, Zheng 2017-09-01 839 should_loop = false; 2a2d927e35dd8d Yan, Zheng 2017-09-01 840 if (ceph_wbc.head_snapc && snapc != last_snapc) { 2a2d927e35dd8d Yan, Zheng 2017-09-01 841 /* where to start/end? */ 2a2d927e35dd8d Yan, Zheng 2017-09-01 842 if (wbc->range_cyclic) { 2a2d927e35dd8d Yan, Zheng 2017-09-01 843 index = start_index; 2a2d927e35dd8d Yan, Zheng 2017-09-01 844 end = -1; 2a2d927e35dd8d Yan, Zheng 2017-09-01 845 if (index > 0) 2a2d927e35dd8d Yan, Zheng 2017-09-01 846 should_loop = true; 2a2d927e35dd8d Yan, Zheng 2017-09-01 847 dout(" cyclic, start at %lu\n", index); 2a2d927e35dd8d Yan, Zheng 2017-09-01 848 } else { 2a2d927e35dd8d Yan, Zheng 2017-09-01 849 index = wbc->range_start >> PAGE_SHIFT; 2a2d927e35dd8d Yan, Zheng 2017-09-01 850 end = wbc->range_end >> PAGE_SHIFT; 2a2d927e35dd8d Yan, Zheng 2017-09-01 851 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) 2a2d927e35dd8d Yan, Zheng 2017-09-01 852 range_whole = true; 2a2d927e35dd8d Yan, Zheng 2017-09-01 853 dout(" not cyclic, %lu to %lu\n", index, end); 2a2d927e35dd8d Yan, Zheng 2017-09-01 854 } 2a2d927e35dd8d Yan, Zheng 2017-09-01 855 } else if (!ceph_wbc.head_snapc) { 2a2d927e35dd8d Yan, Zheng 2017-09-01 856 /* Do not respect wbc->range_{start,end}. Dirty pages 2a2d927e35dd8d Yan, Zheng 2017-09-01 857 * in that range can be associated with newer snapc. 2a2d927e35dd8d Yan, Zheng 2017-09-01 858 * They are not writeable until we write all dirty pages 2a2d927e35dd8d Yan, Zheng 2017-09-01 859 * associated with 'snapc' get written */ 1582af2eaaf17c Yan, Zheng 2018-03-06 860 if (index > 0) 2a2d927e35dd8d Yan, Zheng 2017-09-01 861 should_loop = true; 2a2d927e35dd8d Yan, Zheng 2017-09-01 862 dout(" non-head snapc, range whole\n"); 1d3576fd10f0d7 Sage Weil 2009-10-06 863 } 2a2d927e35dd8d Yan, Zheng 2017-09-01 864 2a2d927e35dd8d Yan, Zheng 2017-09-01 865 ceph_put_snap_context(last_snapc); 1d3576fd10f0d7 Sage Weil 2009-10-06 866 last_snapc = snapc; 1d3576fd10f0d7 Sage Weil 2009-10-06 867 af9cc401ce7452 Yan, Zheng 2018-03-04 868 while (!done && index <= end) { 5b64640cf65be4 Yan, Zheng 2016-01-07 869 int num_ops = 0, op_idx; 0e5ecac7168366 Yan, Zheng 2017-08-31 870 unsigned i, pvec_pages, max_pages, locked_pages = 0; 5b64640cf65be4 Yan, Zheng 2016-01-07 871 struct page **pages = NULL, **data_pages; 1d3576fd10f0d7 Sage Weil 2009-10-06 872 struct page *page; 0e5ecac7168366 Yan, Zheng 2017-08-31 873 pgoff_t strip_unit_end = 0; 5b64640cf65be4 Yan, Zheng 2016-01-07 874 u64 offset = 0, len = 0; a0102bda5bc099 Jeff Layton 2020-07-30 875 bool from_pool = false; 1d3576fd10f0d7 Sage Weil 2009-10-06 876 0e5ecac7168366 Yan, Zheng 2017-08-31 877 max_pages = wsize >> PAGE_SHIFT; 1d3576fd10f0d7 Sage Weil 2009-10-06 878 1d3576fd10f0d7 Sage Weil 2009-10-06 879 get_more_pages: 2e169296603470 Jeff Layton 2020-09-14 880 pvec_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, 2e169296603470 Jeff Layton 2020-09-14 881 end, PAGECACHE_TAG_DIRTY); 0ed75fc8d288f4 Jan Kara 2017-11-15 882 dout("pagevec_lookup_range_tag got %d\n", pvec_pages); 1d3576fd10f0d7 Sage Weil 2009-10-06 883 if (!pvec_pages && !locked_pages) 1d3576fd10f0d7 Sage Weil 2009-10-06 884 break; 1d3576fd10f0d7 Sage Weil 2009-10-06 885 for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) { 1d3576fd10f0d7 Sage Weil 2009-10-06 886 page = pvec.pages[i]; 1d3576fd10f0d7 Sage Weil 2009-10-06 887 dout("? %p idx %lu\n", page, page->index); 1d3576fd10f0d7 Sage Weil 2009-10-06 888 if (locked_pages == 0) 1d3576fd10f0d7 Sage Weil 2009-10-06 889 lock_page(page); /* first page */ 1d3576fd10f0d7 Sage Weil 2009-10-06 890 else if (!trylock_page(page)) 1d3576fd10f0d7 Sage Weil 2009-10-06 891 break; 1d3576fd10f0d7 Sage Weil 2009-10-06 892 1d3576fd10f0d7 Sage Weil 2009-10-06 893 /* only dirty pages, or our accounting breaks */ 1d3576fd10f0d7 Sage Weil 2009-10-06 894 if (unlikely(!PageDirty(page)) || 1d3576fd10f0d7 Sage Weil 2009-10-06 895 unlikely(page->mapping != mapping)) { 1d3576fd10f0d7 Sage Weil 2009-10-06 896 dout("!dirty or !mapping %p\n", page); 1d3576fd10f0d7 Sage Weil 2009-10-06 897 unlock_page(page); 0713e5f24b7deb Yan, Zheng 2017-08-31 898 continue; 1d3576fd10f0d7 Sage Weil 2009-10-06 899 } af9cc401ce7452 Yan, Zheng 2018-03-04 900 /* only if matching snap context */ af9cc401ce7452 Yan, Zheng 2018-03-04 901 pgsnapc = page_snap_context(page); af9cc401ce7452 Yan, Zheng 2018-03-04 902 if (pgsnapc != snapc) { af9cc401ce7452 Yan, Zheng 2018-03-04 903 dout("page snapc %p %lld != oldest %p %lld\n", af9cc401ce7452 Yan, Zheng 2018-03-04 904 pgsnapc, pgsnapc->seq, snapc, snapc->seq); 1582af2eaaf17c Yan, Zheng 2018-03-06 905 if (!should_loop && 1582af2eaaf17c Yan, Zheng 2018-03-06 906 !ceph_wbc.head_snapc && 1582af2eaaf17c Yan, Zheng 2018-03-06 907 wbc->sync_mode != WB_SYNC_NONE) 1582af2eaaf17c Yan, Zheng 2018-03-06 908 should_loop = true; 1d3576fd10f0d7 Sage Weil 2009-10-06 909 unlock_page(page); af9cc401ce7452 Yan, Zheng 2018-03-04 910 continue; 1d3576fd10f0d7 Sage Weil 2009-10-06 911 } 1f934b00e90752 Yan, Zheng 2017-08-30 912 if (page_offset(page) >= ceph_wbc.i_size) { 1f934b00e90752 Yan, Zheng 2017-08-30 913 dout("%p page eof %llu\n", 1f934b00e90752 Yan, Zheng 2017-08-30 914 page, ceph_wbc.i_size); c95f1c5f436bad Erqi Chen 2019-07-24 915 if ((ceph_wbc.size_stable || c95f1c5f436bad Erqi Chen 2019-07-24 916 page_offset(page) >= i_size_read(inode)) && c95f1c5f436bad Erqi Chen 2019-07-24 917 clear_page_dirty_for_io(page)) af9cc401ce7452 Yan, Zheng 2018-03-04 918 mapping->a_ops->invalidatepage(page, 8ff2d290c8ce77 Jeff Layton 2021-04-05 919 0, thp_size(page)); af9cc401ce7452 Yan, Zheng 2018-03-04 920 unlock_page(page); af9cc401ce7452 Yan, Zheng 2018-03-04 921 continue; af9cc401ce7452 Yan, Zheng 2018-03-04 922 } af9cc401ce7452 Yan, Zheng 2018-03-04 923 if (strip_unit_end && (page->index > strip_unit_end)) { af9cc401ce7452 Yan, Zheng 2018-03-04 924 dout("end of strip unit %p\n", page); 1d3576fd10f0d7 Sage Weil 2009-10-06 925 unlock_page(page); 1d3576fd10f0d7 Sage Weil 2009-10-06 926 break; 1d3576fd10f0d7 Sage Weil 2009-10-06 927 } 1702e79734104d Jeff Layton 2021-12-07 928 if (PageWriteback(page) || PageFsCache(page)) { 0713e5f24b7deb Yan, Zheng 2017-08-31 929 if (wbc->sync_mode == WB_SYNC_NONE) { 1d3576fd10f0d7 Sage Weil 2009-10-06 930 dout("%p under writeback\n", page); 1d3576fd10f0d7 Sage Weil 2009-10-06 931 unlock_page(page); 0713e5f24b7deb Yan, Zheng 2017-08-31 932 continue; 0713e5f24b7deb Yan, Zheng 2017-08-31 933 } 0713e5f24b7deb Yan, Zheng 2017-08-31 934 dout("waiting on writeback %p\n", page); 0713e5f24b7deb Yan, Zheng 2017-08-31 935 wait_on_page_writeback(page); 1702e79734104d Jeff Layton 2021-12-07 936 wait_on_page_fscache(page); 1d3576fd10f0d7 Sage Weil 2009-10-06 937 } 1d3576fd10f0d7 Sage Weil 2009-10-06 938 1d3576fd10f0d7 Sage Weil 2009-10-06 939 if (!clear_page_dirty_for_io(page)) { 1d3576fd10f0d7 Sage Weil 2009-10-06 940 dout("%p !clear_page_dirty_for_io\n", page); 1d3576fd10f0d7 Sage Weil 2009-10-06 941 unlock_page(page); 0713e5f24b7deb Yan, Zheng 2017-08-31 942 continue; 1d3576fd10f0d7 Sage Weil 2009-10-06 943 } 1d3576fd10f0d7 Sage Weil 2009-10-06 944 e5975c7c8eb6ae Alex Elder 2013-03-14 945 /* e5975c7c8eb6ae Alex Elder 2013-03-14 946 * We have something to write. If this is e5975c7c8eb6ae Alex Elder 2013-03-14 947 * the first locked page this time through, 5b64640cf65be4 Yan, Zheng 2016-01-07 948 * calculate max possinle write size and 5b64640cf65be4 Yan, Zheng 2016-01-07 949 * allocate a page array e5975c7c8eb6ae Alex Elder 2013-03-14 950 */ 1d3576fd10f0d7 Sage Weil 2009-10-06 951 if (locked_pages == 0) { 5b64640cf65be4 Yan, Zheng 2016-01-07 952 u64 objnum; 5b64640cf65be4 Yan, Zheng 2016-01-07 953 u64 objoff; dccbf08005df80 Ilya Dryomov 2018-02-17 954 u32 xlen; 5b64640cf65be4 Yan, Zheng 2016-01-07 955 1d3576fd10f0d7 Sage Weil 2009-10-06 956 /* prepare async write request */ 6285bc23127741 Alex Elder 2012-10-02 957 offset = (u64)page_offset(page); dccbf08005df80 Ilya Dryomov 2018-02-17 958 ceph_calc_file_object_mapping(&ci->i_layout, dccbf08005df80 Ilya Dryomov 2018-02-17 959 offset, wsize, 5b64640cf65be4 Yan, Zheng 2016-01-07 960 &objnum, &objoff, dccbf08005df80 Ilya Dryomov 2018-02-17 961 &xlen); dccbf08005df80 Ilya Dryomov 2018-02-17 962 len = xlen; 8c71897be2ddfd Henry C Chang 2011-05-03 963 3fb99d483e614b Yanhu Cao 2017-07-21 964 num_ops = 1; 5b64640cf65be4 Yan, Zheng 2016-01-07 965 strip_unit_end = page->index + 09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 966 ((len - 1) >> PAGE_SHIFT); 88486957f9fbf5 Alex Elder 2013-03-14 967 5b64640cf65be4 Yan, Zheng 2016-01-07 968 BUG_ON(pages); 88486957f9fbf5 Alex Elder 2013-03-14 969 max_pages = calc_pages_for(0, (u64)len); 6da2ec56059c3c Kees Cook 2018-06-12 970 pages = kmalloc_array(max_pages, 6da2ec56059c3c Kees Cook 2018-06-12 971 sizeof(*pages), fc2744aa12da71 Yan, Zheng 2013-05-31 972 GFP_NOFS); 88486957f9fbf5 Alex Elder 2013-03-14 973 if (!pages) { a0102bda5bc099 Jeff Layton 2020-07-30 974 from_pool = true; a0102bda5bc099 Jeff Layton 2020-07-30 975 pages = mempool_alloc(ceph_wb_pagevec_pool, GFP_NOFS); e5975c7c8eb6ae Alex Elder 2013-03-14 976 BUG_ON(!pages); 88486957f9fbf5 Alex Elder 2013-03-14 977 } 5b64640cf65be4 Yan, Zheng 2016-01-07 978 5b64640cf65be4 Yan, Zheng 2016-01-07 979 len = 0; 5b64640cf65be4 Yan, Zheng 2016-01-07 980 } else if (page->index != 09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 981 (offset + len) >> PAGE_SHIFT) { a0102bda5bc099 Jeff Layton 2020-07-30 982 if (num_ops >= (from_pool ? CEPH_OSD_SLAB_OPS : 5b64640cf65be4 Yan, Zheng 2016-01-07 983 CEPH_OSD_MAX_OPS)) { 5b64640cf65be4 Yan, Zheng 2016-01-07 984 redirty_page_for_writepage(wbc, page); 5b64640cf65be4 Yan, Zheng 2016-01-07 985 unlock_page(page); 5b64640cf65be4 Yan, Zheng 2016-01-07 986 break; 5b64640cf65be4 Yan, Zheng 2016-01-07 987 } 5b64640cf65be4 Yan, Zheng 2016-01-07 988 5b64640cf65be4 Yan, Zheng 2016-01-07 989 num_ops++; 5b64640cf65be4 Yan, Zheng 2016-01-07 990 offset = (u64)page_offset(page); 5b64640cf65be4 Yan, Zheng 2016-01-07 991 len = 0; 1d3576fd10f0d7 Sage Weil 2009-10-06 992 } 1d3576fd10f0d7 Sage Weil 2009-10-06 993 1d3576fd10f0d7 Sage Weil 2009-10-06 994 /* note position of first page in pvec */ 1d3576fd10f0d7 Sage Weil 2009-10-06 995 dout("%p will write page %p idx %lu\n", 1d3576fd10f0d7 Sage Weil 2009-10-06 996 inode, page, page->index); 2baba25019ec56 Yehuda Sadeh 2009-12-18 997 5b64640cf65be4 Yan, Zheng 2016-01-07 998 if (atomic_long_inc_return(&fsc->writeback_count) > 5b64640cf65be4 Yan, Zheng 2016-01-07 999 CONGESTION_ON_THRESH( 3d14c5d2b6e15c Yehuda Sadeh 2010-04-06 1000 fsc->mount_options->congestion_kb)) { 09dc9fc24ba714 Jan Kara 2017-04-12 1001 set_bdi_congested(inode_to_bdi(inode), 213c99ee0cf17f Sage Weil 2010-08-03 1002 BLK_RW_ASYNC); 2baba25019ec56 Yehuda Sadeh 2009-12-18 1003 } 2baba25019ec56 Yehuda Sadeh 2009-12-18 1004 0713e5f24b7deb Yan, Zheng 2017-08-31 1005 0713e5f24b7deb Yan, Zheng 2017-08-31 1006 pages[locked_pages++] = page; 0713e5f24b7deb Yan, Zheng 2017-08-31 1007 pvec.pages[i] = NULL; 0713e5f24b7deb Yan, Zheng 2017-08-31 1008 8ff2d290c8ce77 Jeff Layton 2021-04-05 1009 len += thp_size(page); 1d3576fd10f0d7 Sage Weil 2009-10-06 1010 } 1d3576fd10f0d7 Sage Weil 2009-10-06 1011 1d3576fd10f0d7 Sage Weil 2009-10-06 1012 /* did we get anything? */ 1d3576fd10f0d7 Sage Weil 2009-10-06 1013 if (!locked_pages) 1d3576fd10f0d7 Sage Weil 2009-10-06 1014 goto release_pvec_pages; 1d3576fd10f0d7 Sage Weil 2009-10-06 1015 if (i) { 0713e5f24b7deb Yan, Zheng 2017-08-31 1016 unsigned j, n = 0; 0713e5f24b7deb Yan, Zheng 2017-08-31 1017 /* shift unused page to beginning of pvec */ 0713e5f24b7deb Yan, Zheng 2017-08-31 1018 for (j = 0; j < pvec_pages; j++) { 0713e5f24b7deb Yan, Zheng 2017-08-31 1019 if (!pvec.pages[j]) 0713e5f24b7deb Yan, Zheng 2017-08-31 1020 continue; 0713e5f24b7deb Yan, Zheng 2017-08-31 1021 if (n < j) 0713e5f24b7deb Yan, Zheng 2017-08-31 1022 pvec.pages[n] = pvec.pages[j]; 0713e5f24b7deb Yan, Zheng 2017-08-31 1023 n++; 0713e5f24b7deb Yan, Zheng 2017-08-31 1024 } 0713e5f24b7deb Yan, Zheng 2017-08-31 1025 pvec.nr = n; 1d3576fd10f0d7 Sage Weil 2009-10-06 1026 1d3576fd10f0d7 Sage Weil 2009-10-06 1027 if (pvec_pages && i == pvec_pages && 1d3576fd10f0d7 Sage Weil 2009-10-06 1028 locked_pages < max_pages) { 1d3576fd10f0d7 Sage Weil 2009-10-06 1029 dout("reached end pvec, trying for more\n"); 0713e5f24b7deb Yan, Zheng 2017-08-31 1030 pagevec_release(&pvec); 1d3576fd10f0d7 Sage Weil 2009-10-06 1031 goto get_more_pages; 1d3576fd10f0d7 Sage Weil 2009-10-06 1032 } 1d3576fd10f0d7 Sage Weil 2009-10-06 1033 } 1d3576fd10f0d7 Sage Weil 2009-10-06 1034 5b64640cf65be4 Yan, Zheng 2016-01-07 1035 new_request: e5975c7c8eb6ae Alex Elder 2013-03-14 1036 offset = page_offset(pages[0]); 5b64640cf65be4 Yan, Zheng 2016-01-07 1037 len = wsize; 5b64640cf65be4 Yan, Zheng 2016-01-07 1038 5b64640cf65be4 Yan, Zheng 2016-01-07 1039 req = ceph_osdc_new_request(&fsc->client->osdc, 5b64640cf65be4 Yan, Zheng 2016-01-07 1040 &ci->i_layout, vino, 5b64640cf65be4 Yan, Zheng 2016-01-07 1041 offset, &len, 0, num_ops, 1f934b00e90752 Yan, Zheng 2017-08-30 1042 CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE, 1f934b00e90752 Yan, Zheng 2017-08-30 1043 snapc, ceph_wbc.truncate_seq, 1f934b00e90752 Yan, Zheng 2017-08-30 1044 ceph_wbc.truncate_size, false); 5b64640cf65be4 Yan, Zheng 2016-01-07 1045 if (IS_ERR(req)) { 5b64640cf65be4 Yan, Zheng 2016-01-07 1046 req = ceph_osdc_new_request(&fsc->client->osdc, 5b64640cf65be4 Yan, Zheng 2016-01-07 1047 &ci->i_layout, vino, 5b64640cf65be4 Yan, Zheng 2016-01-07 1048 offset, &len, 0, 5b64640cf65be4 Yan, Zheng 2016-01-07 1049 min(num_ops, 5b64640cf65be4 Yan, Zheng 2016-01-07 1050 CEPH_OSD_SLAB_OPS), 5b64640cf65be4 Yan, Zheng 2016-01-07 1051 CEPH_OSD_OP_WRITE, 54ea0046b6fe36 Ilya Dryomov 2017-02-11 1052 CEPH_OSD_FLAG_WRITE, 1f934b00e90752 Yan, Zheng 2017-08-30 1053 snapc, ceph_wbc.truncate_seq, 1f934b00e90752 Yan, Zheng 2017-08-30 1054 ceph_wbc.truncate_size, true); 5b64640cf65be4 Yan, Zheng 2016-01-07 1055 BUG_ON(IS_ERR(req)); 5b64640cf65be4 Yan, Zheng 2016-01-07 1056 } 5b64640cf65be4 Yan, Zheng 2016-01-07 1057 BUG_ON(len < page_offset(pages[locked_pages - 1]) + 8ff2d290c8ce77 Jeff Layton 2021-04-05 1058 thp_size(page) - offset); 5b64640cf65be4 Yan, Zheng 2016-01-07 1059 5b64640cf65be4 Yan, Zheng 2016-01-07 1060 req->r_callback = writepages_finish; 5b64640cf65be4 Yan, Zheng 2016-01-07 1061 req->r_inode = inode; 5b64640cf65be4 Yan, Zheng 2016-01-07 1062 5b64640cf65be4 Yan, Zheng 2016-01-07 1063 /* Format the osd request message and submit the write */ 5b64640cf65be4 Yan, Zheng 2016-01-07 1064 len = 0; 5b64640cf65be4 Yan, Zheng 2016-01-07 1065 data_pages = pages; 5b64640cf65be4 Yan, Zheng 2016-01-07 1066 op_idx = 0; 5b64640cf65be4 Yan, Zheng 2016-01-07 1067 for (i = 0; i < locked_pages; i++) { 5b64640cf65be4 Yan, Zheng 2016-01-07 1068 u64 cur_offset = page_offset(pages[i]); 1702e79734104d Jeff Layton 2021-12-07 1069 /* 1702e79734104d Jeff Layton 2021-12-07 1070 * Discontinuity in page range? Ceph can handle that by just passing 1702e79734104d Jeff Layton 2021-12-07 1071 * multiple extents in the write op. 1702e79734104d Jeff Layton 2021-12-07 1072 */ 5b64640cf65be4 Yan, Zheng 2016-01-07 1073 if (offset + len != cur_offset) { 1702e79734104d Jeff Layton 2021-12-07 1074 /* If it's full, stop here */ 3fb99d483e614b Yanhu Cao 2017-07-21 1075 if (op_idx + 1 == req->r_num_ops) 5b64640cf65be4 Yan, Zheng 2016-01-07 1076 break; 1702e79734104d Jeff Layton 2021-12-07 1077 1702e79734104d Jeff Layton 2021-12-07 1078 /* Kick off an fscache write with what we have so far. */ 1702e79734104d Jeff Layton 2021-12-07 1079 ceph_fscache_write_to_cache(inode, offset, len, caching); 1702e79734104d Jeff Layton 2021-12-07 1080 1702e79734104d Jeff Layton 2021-12-07 1081 /* Start a new extent */ 5b64640cf65be4 Yan, Zheng 2016-01-07 1082 osd_req_op_extent_dup_last(req, op_idx, 5b64640cf65be4 Yan, Zheng 2016-01-07 1083 cur_offset - offset); 5b64640cf65be4 Yan, Zheng 2016-01-07 1084 dout("writepages got pages at %llu~%llu\n", 5b64640cf65be4 Yan, Zheng 2016-01-07 1085 offset, len); 5b64640cf65be4 Yan, Zheng 2016-01-07 1086 osd_req_op_extent_osd_data_pages(req, op_idx, 5b64640cf65be4 Yan, Zheng 2016-01-07 1087 data_pages, len, 0, a0102bda5bc099 Jeff Layton 2020-07-30 1088 from_pool, false); 5b64640cf65be4 Yan, Zheng 2016-01-07 1089 osd_req_op_extent_update(req, op_idx, len); 5b64640cf65be4 Yan, Zheng 2016-01-07 1090 5b64640cf65be4 Yan, Zheng 2016-01-07 1091 len = 0; 5b64640cf65be4 Yan, Zheng 2016-01-07 1092 offset = cur_offset; 5b64640cf65be4 Yan, Zheng 2016-01-07 1093 data_pages = pages + i; 5b64640cf65be4 Yan, Zheng 2016-01-07 1094 op_idx++; 5b64640cf65be4 Yan, Zheng 2016-01-07 1095 } 5b64640cf65be4 Yan, Zheng 2016-01-07 1096 5b64640cf65be4 Yan, Zheng 2016-01-07 1097 set_page_writeback(pages[i]); 1702e79734104d Jeff Layton 2021-12-07 1098 if (caching) 1702e79734104d Jeff Layton 2021-12-07 1099 ceph_set_page_fscache(pages[i]); 8ff2d290c8ce77 Jeff Layton 2021-04-05 1100 len += thp_size(page); 5b64640cf65be4 Yan, Zheng 2016-01-07 1101 } 1702e79734104d Jeff Layton 2021-12-07 1102 ceph_fscache_write_to_cache(inode, offset, len, caching); 5b64640cf65be4 Yan, Zheng 2016-01-07 1103 1f934b00e90752 Yan, Zheng 2017-08-30 1104 if (ceph_wbc.size_stable) { 1f934b00e90752 Yan, Zheng 2017-08-30 1105 len = min(len, ceph_wbc.i_size - offset); 5b64640cf65be4 Yan, Zheng 2016-01-07 1106 } else if (i == locked_pages) { e1966b49446a43 Yan, Zheng 2015-06-18 1107 /* writepages_finish() clears writeback pages e1966b49446a43 Yan, Zheng 2015-06-18 1108 * according to the data length, so make sure e1966b49446a43 Yan, Zheng 2015-06-18 1109 * data length covers all locked pages */ 8ff2d290c8ce77 Jeff Layton 2021-04-05 1110 u64 min_len = len + 1 - thp_size(page); 1f934b00e90752 Yan, Zheng 2017-08-30 1111 len = get_writepages_data_length(inode, pages[i - 1], 1f934b00e90752 Yan, Zheng 2017-08-30 1112 offset); 5b64640cf65be4 Yan, Zheng 2016-01-07 1113 len = max(len, min_len); e1966b49446a43 Yan, Zheng 2015-06-18 1114 } 5b64640cf65be4 Yan, Zheng 2016-01-07 1115 dout("writepages got pages at %llu~%llu\n", offset, len); 1d3576fd10f0d7 Sage Weil 2009-10-06 1116 5b64640cf65be4 Yan, Zheng 2016-01-07 1117 osd_req_op_extent_osd_data_pages(req, op_idx, data_pages, len, a0102bda5bc099 Jeff Layton 2020-07-30 1118 0, from_pool, false); 5b64640cf65be4 Yan, Zheng 2016-01-07 1119 osd_req_op_extent_update(req, op_idx, len); e5975c7c8eb6ae Alex Elder 2013-03-14 1120 5b64640cf65be4 Yan, Zheng 2016-01-07 1121 BUG_ON(op_idx + 1 != req->r_num_ops); e5975c7c8eb6ae Alex Elder 2013-03-14 1122 a0102bda5bc099 Jeff Layton 2020-07-30 1123 from_pool = false; 5b64640cf65be4 Yan, Zheng 2016-01-07 1124 if (i < locked_pages) { 5b64640cf65be4 Yan, Zheng 2016-01-07 1125 BUG_ON(num_ops <= req->r_num_ops); 5b64640cf65be4 Yan, Zheng 2016-01-07 1126 num_ops -= req->r_num_ops; 5b64640cf65be4 Yan, Zheng 2016-01-07 1127 locked_pages -= i; 5b64640cf65be4 Yan, Zheng 2016-01-07 1128 5b64640cf65be4 Yan, Zheng 2016-01-07 1129 /* allocate new pages array for next request */ 5b64640cf65be4 Yan, Zheng 2016-01-07 1130 data_pages = pages; 6da2ec56059c3c Kees Cook 2018-06-12 1131 pages = kmalloc_array(locked_pages, sizeof(*pages), 5b64640cf65be4 Yan, Zheng 2016-01-07 1132 GFP_NOFS); 5b64640cf65be4 Yan, Zheng 2016-01-07 1133 if (!pages) { a0102bda5bc099 Jeff Layton 2020-07-30 1134 from_pool = true; a0102bda5bc099 Jeff Layton 2020-07-30 1135 pages = mempool_alloc(ceph_wb_pagevec_pool, GFP_NOFS); 5b64640cf65be4 Yan, Zheng 2016-01-07 1136 BUG_ON(!pages); 5b64640cf65be4 Yan, Zheng 2016-01-07 1137 } 5b64640cf65be4 Yan, Zheng 2016-01-07 1138 memcpy(pages, data_pages + i, 5b64640cf65be4 Yan, Zheng 2016-01-07 1139 locked_pages * sizeof(*pages)); 5b64640cf65be4 Yan, Zheng 2016-01-07 1140 memset(data_pages + i, 0, 5b64640cf65be4 Yan, Zheng 2016-01-07 1141 locked_pages * sizeof(*pages)); 5b64640cf65be4 Yan, Zheng 2016-01-07 1142 } else { 5b64640cf65be4 Yan, Zheng 2016-01-07 1143 BUG_ON(num_ops != req->r_num_ops); 5b64640cf65be4 Yan, Zheng 2016-01-07 1144 index = pages[i - 1]->index + 1; 5b64640cf65be4 Yan, Zheng 2016-01-07 1145 /* request message now owns the pages array */ 5b64640cf65be4 Yan, Zheng 2016-01-07 1146 pages = NULL; 5b64640cf65be4 Yan, Zheng 2016-01-07 1147 } e5975c7c8eb6ae Alex Elder 2013-03-14 1148 fac02ddf910814 Arnd Bergmann 2018-07-13 1149 req->r_mtime = inode->i_mtime; 9d6fcb081a4770 Sage Weil 2011-05-12 1150 rc = ceph_osdc_start_request(&fsc->client->osdc, req, true); 9d6fcb081a4770 Sage Weil 2011-05-12 1151 BUG_ON(rc); 1d3576fd10f0d7 Sage Weil 2009-10-06 1152 req = NULL; 1d3576fd10f0d7 Sage Weil 2009-10-06 1153 5b64640cf65be4 Yan, Zheng 2016-01-07 1154 wbc->nr_to_write -= i; 5b64640cf65be4 Yan, Zheng 2016-01-07 1155 if (pages) 5b64640cf65be4 Yan, Zheng 2016-01-07 1156 goto new_request; 5b64640cf65be4 Yan, Zheng 2016-01-07 1157 2a2d927e35dd8d Yan, Zheng 2017-09-01 1158 /* 2a2d927e35dd8d Yan, Zheng 2017-09-01 1159 * We stop writing back only if we are not doing 2a2d927e35dd8d Yan, Zheng 2017-09-01 1160 * integrity sync. In case of integrity sync we have to 2a2d927e35dd8d Yan, Zheng 2017-09-01 1161 * keep going until we have written all the pages 2a2d927e35dd8d Yan, Zheng 2017-09-01 1162 * we tagged for writeback prior to entering this loop. 2a2d927e35dd8d Yan, Zheng 2017-09-01 1163 */ 2a2d927e35dd8d Yan, Zheng 2017-09-01 1164 if (wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) af9cc401ce7452 Yan, Zheng 2018-03-04 1165 done = true; 1d3576fd10f0d7 Sage Weil 2009-10-06 1166 1d3576fd10f0d7 Sage Weil 2009-10-06 1167 release_pvec_pages: 1d3576fd10f0d7 Sage Weil 2009-10-06 1168 dout("pagevec_release on %d pages (%p)\n", (int)pvec.nr, 1d3576fd10f0d7 Sage Weil 2009-10-06 1169 pvec.nr ? pvec.pages[0] : NULL); 1d3576fd10f0d7 Sage Weil 2009-10-06 1170 pagevec_release(&pvec); 1d3576fd10f0d7 Sage Weil 2009-10-06 1171 } 1d3576fd10f0d7 Sage Weil 2009-10-06 1172 1d3576fd10f0d7 Sage Weil 2009-10-06 1173 if (should_loop && !done) { 1d3576fd10f0d7 Sage Weil 2009-10-06 1174 /* more to do; loop back to beginning of file */ 1d3576fd10f0d7 Sage Weil 2009-10-06 1175 dout("writepages looping back to beginning of file\n"); 2a2d927e35dd8d Yan, Zheng 2017-09-01 1176 end = start_index - 1; /* OK even when start_index == 0 */ f275635ee0b664 Yan, Zheng 2017-09-01 1177 f275635ee0b664 Yan, Zheng 2017-09-01 1178 /* to write dirty pages associated with next snapc, f275635ee0b664 Yan, Zheng 2017-09-01 1179 * we need to wait until current writes complete */ f275635ee0b664 Yan, Zheng 2017-09-01 1180 if (wbc->sync_mode != WB_SYNC_NONE && f275635ee0b664 Yan, Zheng 2017-09-01 1181 start_index == 0 && /* all dirty pages were checked */ f275635ee0b664 Yan, Zheng 2017-09-01 1182 !ceph_wbc.head_snapc) { f275635ee0b664 Yan, Zheng 2017-09-01 1183 struct page *page; f275635ee0b664 Yan, Zheng 2017-09-01 1184 unsigned i, nr; f275635ee0b664 Yan, Zheng 2017-09-01 1185 index = 0; f275635ee0b664 Yan, Zheng 2017-09-01 1186 while ((index <= end) && f275635ee0b664 Yan, Zheng 2017-09-01 1187 (nr = pagevec_lookup_tag(&pvec, mapping, &index, 67fd707f468142 Jan Kara 2017-11-15 1188 PAGECACHE_TAG_WRITEBACK))) { f275635ee0b664 Yan, Zheng 2017-09-01 1189 for (i = 0; i < nr; i++) { f275635ee0b664 Yan, Zheng 2017-09-01 1190 page = pvec.pages[i]; f275635ee0b664 Yan, Zheng 2017-09-01 1191 if (page_snap_context(page) != snapc) f275635ee0b664 Yan, Zheng 2017-09-01 1192 continue; f275635ee0b664 Yan, Zheng 2017-09-01 1193 wait_on_page_writeback(page); f275635ee0b664 Yan, Zheng 2017-09-01 1194 } f275635ee0b664 Yan, Zheng 2017-09-01 1195 pagevec_release(&pvec); f275635ee0b664 Yan, Zheng 2017-09-01 1196 cond_resched(); f275635ee0b664 Yan, Zheng 2017-09-01 1197 } f275635ee0b664 Yan, Zheng 2017-09-01 1198 } f275635ee0b664 Yan, Zheng 2017-09-01 1199 2a2d927e35dd8d Yan, Zheng 2017-09-01 1200 start_index = 0; 1d3576fd10f0d7 Sage Weil 2009-10-06 1201 index = 0; 1d3576fd10f0d7 Sage Weil 2009-10-06 1202 goto retry; 1d3576fd10f0d7 Sage Weil 2009-10-06 1203 } 1d3576fd10f0d7 Sage Weil 2009-10-06 1204 1d3576fd10f0d7 Sage Weil 2009-10-06 1205 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 1d3576fd10f0d7 Sage Weil 2009-10-06 1206 mapping->writeback_index = index; 1d3576fd10f0d7 Sage Weil 2009-10-06 1207 1d3576fd10f0d7 Sage Weil 2009-10-06 1208 out: 1d3576fd10f0d7 Sage Weil 2009-10-06 1209 ceph_osdc_put_request(req); 2a2d927e35dd8d Yan, Zheng 2017-09-01 1210 ceph_put_snap_context(last_snapc); 2a2d927e35dd8d Yan, Zheng 2017-09-01 1211 dout("writepages dend - startone, rc = %d\n", rc); 1d3576fd10f0d7 Sage Weil 2009-10-06 1212 return rc; 1d3576fd10f0d7 Sage Weil 2009-10-06 1213 } 1d3576fd10f0d7 Sage Weil 2009-10-06 1214 :::::: The code at line 788 was first introduced by commit :::::: 1d3576fd10f0d7a104204267b81cf84a07028dad ceph: address space operations :::::: TO: Sage Weil :::::: CC: Sage Weil --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org