Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp25099lqs; Thu, 13 Jun 2024 02:39:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6nOLSgc3cufUfQoq8WoBHMBnZmgm2vdJdbn6GX2GOWPN96UXZiQap7CvOY24STPKGgKP6svVK/dah0aVGMf0/wSFIa8iP0v+nYcoJIA== X-Google-Smtp-Source: AGHT+IFZlR5PjGXHUnULItGzpx2X2fjeSnNZAyxqGusubtuB7XJMmocIeq11QG01gvRZIFtGL72c X-Received: by 2002:a05:6808:199d:b0:3d2:2ab0:1f2e with SMTP id 5614622812f47-3d23de9942fmr4143358b6e.0.1718271584673; Thu, 13 Jun 2024 02:39:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718271584; cv=pass; d=google.com; s=arc-20160816; b=yjHNVUFDH1aE3fs2VXzNDDEY+93BgAyP8b3yehBGcDT3J3qpsEQoIOlTFZ1NLudnnX G5TmSz/tvWpuOJ52I7dQsR2qTvOh6C5cb+FgS6MvIHmj2s0e+372iaDEMwdhfjmChto6 +XpWRD+5ihPwXXCVjBTKi+a8XmDK4SR2WRpDeTIkBkdGCu4RjBkJ+6/VTCVhKcVYsDXD w0PXn7d/i3oXt4t3Iw3UGRfMel2OA6p42ZnThG6elkgvYssyNDszG+7s0rm/UcMZyFSn fuW7BdFjV6N04+5ARh9NKLbne00tzO1TByTO8QQJHbR4h+OKAsY8dAuR25kAq/Cb7CMN Efdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=T771Cm3gG+LO2ulH7lePHD6pyylm5bilZZmIslk4xUg=; fh=FjGUeRKuY5Vkps/iCklb/wXg4EmcfkRK+rw0nvXgsb0=; b=SbFuOBOOHP0zqAhgUfzuzwqut2sxbTKtr5wRVYRbW6XGwhXuVqxeb+t4/1//+rshpz KTw4aYPdG3Bn225vN3OvaDVVwqZJJve3TTX+pdUO15KkQbl4KtNGQ55nf1D/1WUPSBkN 3ia1IJP0CXEE+wFwAs6oHpNHPo7sSkXr66ybQXzdtc2aV8+pEGkRD4SIiMtTHOWS99uB EVoO8xo99Cq4mVstBqikd+xYs0im2rnDgc+VV4bal7bUoXBrFlhzcpZ4fCchoLv1CNVT GPFLvFYqqg4a39P3QR5K0yF41B5o5ABLKM9KKtmOdAjz+wYb/FuI/BWoI5T0j0oNy2Jw ftcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-212966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212966-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee4167bcbsi942444a12.454.2024.06.13.02.39.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 02:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-212966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212966-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 36E4C284186 for ; Thu, 13 Jun 2024 09:37:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8056F13F447; Thu, 13 Jun 2024 09:37:00 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6834F13CABC for ; Thu, 13 Jun 2024 09:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718271420; cv=none; b=H9se83X+uYYDF/rL39wBopaHksQlFlG8/DjvshR5jFygRxj18312/mn2kv4T2aFVt05d0lPhvyeQxdUTCjWXBPfbuotsWxJ5ygxyd+Fje7npB8I9iX71CpM5geK7pQGAcSHsv4l2IcCE7IfVXMjWGQKThP41qizwvBjYnx4zqyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718271420; c=relaxed/simple; bh=UK3WzRpVVhjaYnEumT7PaqistOVUQ3IJ6RyLMIuezXA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=O31d8mmOCdsXZJvWJfjff7g/d+S9j2afk6ftfC4JD/JoYdSnJaebYUMotCT0gFDfUDRjbrabAZ8tN0RLbIa4mup/BnZuvLls32MjdP4joAME0nmCh9sEe7HjTY9NXNBdNtyANE3vRKmYsPi5cNOj3Mrg9a8AmKIhi6uAt8tdNwE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 45D9ZqpC082721; Thu, 13 Jun 2024 17:35:52 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4W0HGw1xS0z2S2vmG; Thu, 13 Jun 2024 17:31:36 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 13 Jun 2024 17:35:50 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH] f2fs: fix to use mnt_{want,drop}_write_file replace file_{start,end}_wrtie Date: Thu, 13 Jun 2024 17:35:33 +0800 Message-ID: <1718271333-32179-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 45D9ZqpC082721 mnt_{want,drop}_write_file is more suitable than file_{start,end}_wrtie and also is consistent with other ioctl operations. Signed-off-by: Zhiguo Niu --- fs/f2fs/file.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c50213d..e4a7cff 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3935,7 +3935,9 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) IS_ENCRYPTED(inode) && f2fs_is_multi_device(sbi))) return -EOPNOTSUPP; - file_start_write(filp); + ret = mnt_want_write_file(filp); + if (ret) + return ret; inode_lock(inode); if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) || @@ -4061,7 +4063,7 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); err: inode_unlock(inode); - file_end_write(filp); + mnt_drop_write_file(filp); return ret; } @@ -4115,7 +4117,9 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) option.algorithm >= COMPRESS_MAX) return -EINVAL; - file_start_write(filp); + ret = mnt_want_write_file(filp); + if (ret) + return ret; inode_lock(inode); f2fs_down_write(&F2FS_I(inode)->i_sem); @@ -4154,7 +4158,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) out: f2fs_up_write(&F2FS_I(inode)->i_sem); inode_unlock(inode); - file_end_write(filp); + mnt_drop_write_file(filp); return ret; } @@ -4211,7 +4215,9 @@ static int f2fs_ioc_decompress_file(struct file *filp) f2fs_balance_fs(sbi, true); - file_start_write(filp); + ret = mnt_want_write_file(filp); + if (ret) + return ret; inode_lock(inode); if (!f2fs_is_compress_backend_ready(inode)) { @@ -4266,7 +4272,7 @@ static int f2fs_ioc_decompress_file(struct file *filp) f2fs_update_time(sbi, REQ_TIME); out: inode_unlock(inode); - file_end_write(filp); + mnt_drop_write_file(filp); return ret; } @@ -4288,7 +4294,9 @@ static int f2fs_ioc_compress_file(struct file *filp) f2fs_balance_fs(sbi, true); - file_start_write(filp); + ret = mnt_want_write_file(filp); + if (ret) + return ret; inode_lock(inode); if (!f2fs_is_compress_backend_ready(inode)) { @@ -4344,7 +4352,7 @@ static int f2fs_ioc_compress_file(struct file *filp) f2fs_update_time(sbi, REQ_TIME); out: inode_unlock(inode); - file_end_write(filp); + mnt_drop_write_file(filp); return ret; } -- 1.9.1