Received: by 10.192.165.156 with SMTP id m28csp2076369imm; Thu, 12 Apr 2018 08:13:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx48WbhDL1Y03ZF1JuuD12L2/IKoMFIsSUwtPz+OU5AlQ0AUzNkbwCqTs9OpJh5utnOpDSyV1 X-Received: by 10.99.53.142 with SMTP id c136mr1025508pga.37.1523546023922; Thu, 12 Apr 2018 08:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523546023; cv=none; d=google.com; s=arc-20160816; b=EqBc3duwhXGFALMvooNSbrZwQ2p88cGKme+roNoYWeffoKeKrNS9NldAylSQQeFRoO NJmzmI0kkaGOZEfJvzVpwzfvvR/EaKdX94VK9AdKxNLKHTTgwFDestYvhY54K8SsL0lE wYXK8eYCaXAYw2tLYwUEDD561WTQM/S2SeChcOGHtgAHbYdxBMBqXkf8X4vx9a2ifmgp gyKcU9ZTervpPL6Pyr0D7VrQdurWoZgWA3AzTCdy/Vo4AywqlOcbL3x8sRxM2wcwdBoo wgRSbT+2H2p5QOm/aJYp63gyyr7S8+lV3mAYEwcoOttfHiLS9UDn4MzkDLGKnxtKbEJp m+wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=PgLr7qG9OvlEPhLs3gSmZZyIeFcXG3dsaCYVpHacJl0=; b=ufPQ/wrWG6KeJGR51AYeSjEYIQqcRETkiwAr5MJx5bQPxMTRus878JP7WfwhBbX8RV NI2VPxPoAWMJZldJ18sq9hYtWGvW3omPdmnuiZ+vLUm60sxf6DBNz2jWqqsFe6TqT1bQ 8epVgP8zkXBSIMf7d2kfmOnJy5yVN2ueAJbGrT44zsKxuxI4+ypjHA16JPWFYvIlzBZn GUJUeFi1W8sGHRjHVnk3jaNfbYvLc9vcX5rfSvn4nZ1ndoSESsCFIPqeC3kGByrPT6gb BRc6m8cjrMpjAeofB0rha+DAn/qCiBrZSwWUWL8WP1XMntD2oWqsd6qHW/0QbmBQWmWO VQ7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si68140pgc.731.2018.04.12.08.13.06; Thu, 12 Apr 2018 08:13:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbeDLPJN (ORCPT + 99 others); Thu, 12 Apr 2018 11:09:13 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36840 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753645AbeDLPJK (ORCPT ); Thu, 12 Apr 2018 11:09:10 -0400 Received: by mail-wr0-f194.google.com with SMTP id q13so2037659wre.3 for ; Thu, 12 Apr 2018 08:09:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PgLr7qG9OvlEPhLs3gSmZZyIeFcXG3dsaCYVpHacJl0=; b=sAzpXKFIFtWvs+jRty+YGzA1btdheXfcumpIKpuiui8Xpn6E0kL3r3x6kx8aRb9xl8 m8cNa7Wd3F3jFLAD0FbmX/HlWsSMe5h3e37k/msaxTKS0xel4KC/wrCVD5JAxk9MuPm6 B18u90FRJpPOZiZpH/FodvNaqh1gayoEeA5ZbDr1njbJ4vSJVSdkSBM5in5vYr1Mzkdo ha+dP1vqFHwr1o90d6tKicZ5bLHWD2/o7PnTr6+LsTKJ4HY1qskk8d6Q8cR4wc0xoTDZ bQoOQ75sr7fett1AlpFPDtBl1Q3nZzSFZwqBkEDaXf8izdYb8OVMy+SsenHKgT5AbIF+ 6JKg== X-Gm-Message-State: ALQs6tBK9L7+jEzl5jTvhTL5ifbJ3kyGfVp0VGZdOlA9JaHiZStkpedk MY7bMiY7J2M/ciXtvQuqJcUbSQ== X-Received: by 10.223.152.142 with SMTP id w14mr1179553wrb.210.1523545748895; Thu, 12 Apr 2018 08:09:08 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id p197sm2621783wme.43.2018.04.12.08.09.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:09:08 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 32/35] Partially revert "locks: fix file locking on overlayfs" Date: Thu, 12 Apr 2018 17:08:23 +0200 Message-Id: <20180412150826.20988-33-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This partially reverts commit c568d68341be7030f5647def68851e469b21ca11. Overlayfs files will now automatically get the correct locks, no need to hack overlay support in VFS. It is a partial revert, because it leaves the locks_inode() calls in place and defines locks_inode() to file_inode(). We could revert those as well, but it would be unnecessary code churn and it makes sense to document that we are getting the inode for locking purposes. Signed-off-by: Miklos Szeredi --- fs/locks.c | 17 ++++++----------- fs/overlayfs/super.c | 2 +- include/linux/fs.h | 13 +------------ include/uapi/linux/fs.h | 1 - 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 8e9431a178a5..55069318b984 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -139,11 +139,6 @@ #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) #define IS_REMOTELCK(fl) (fl->fl_pid <= 0) -static inline bool is_remote_lock(struct file *filp) -{ - return likely(!(filp->f_path.dentry->d_sb->s_flags & SB_NOREMOTELOCK)); -} - static bool lease_breaking(struct file_lock *fl) { return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); @@ -1875,7 +1870,7 @@ EXPORT_SYMBOL(generic_setlease); int vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv) { - if (filp->f_op->setlease && is_remote_lock(filp)) + if (filp->f_op->setlease) return filp->f_op->setlease(filp, arg, lease, priv); else return generic_setlease(filp, arg, lease, priv); @@ -2022,7 +2017,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) if (error) goto out_free; - if (f.file->f_op->flock && is_remote_lock(f.file)) + if (f.file->f_op->flock) error = f.file->f_op->flock(f.file, (can_sleep) ? F_SETLKW : F_SETLK, lock); @@ -2048,7 +2043,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) */ int vfs_test_lock(struct file *filp, struct file_lock *fl) { - if (filp->f_op->lock && is_remote_lock(filp)) + if (filp->f_op->lock) return filp->f_op->lock(filp, F_GETLK, fl); posix_test_lock(filp, fl); return 0; @@ -2191,7 +2186,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock) */ int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) { - if (filp->f_op->lock && is_remote_lock(filp)) + if (filp->f_op->lock) return filp->f_op->lock(filp, cmd, fl); else return posix_lock_file(filp, fl, conf); @@ -2513,7 +2508,7 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx) if (list_empty(&flctx->flc_flock)) return; - if (filp->f_op->flock && is_remote_lock(filp)) + if (filp->f_op->flock) filp->f_op->flock(filp, F_SETLKW, &fl); else flock_lock_inode(inode, &fl); @@ -2600,7 +2595,7 @@ EXPORT_SYMBOL(posix_unblock_lock); */ int vfs_cancel_lock(struct file *filp, struct file_lock *fl) { - if (filp->f_op->lock && is_remote_lock(filp)) + if (filp->f_op->lock) return filp->f_op->lock(filp, F_CANCELLK, fl); return 0; } diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 7779fc610767..f2a83fabe2eb 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1479,7 +1479,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) sb->s_op = &ovl_super_operations; sb->s_xattr = ovl_xattr_handlers; sb->s_fs_info = ofs; - sb->s_flags |= SB_POSIXACL | SB_NOREMOTELOCK; + sb->s_flags |= SB_POSIXACL; err = -ENOMEM; root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, 0)); diff --git a/include/linux/fs.h b/include/linux/fs.h index 5294697217b7..6db6e83004d6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1050,17 +1050,7 @@ struct file_lock_context { extern void send_sigio(struct fown_struct *fown, int fd, int band); -/* - * Return the inode to use for locking - * - * For overlayfs this should be the overlay inode, not the real inode returned - * by file_inode(). For any other fs file_inode(filp) and locks_inode(filp) are - * equal. - */ -static inline struct inode *locks_inode(const struct file *f) -{ - return f->f_path.dentry->d_inode; -} +#define locks_inode(f) file_inode(f) #ifdef CONFIG_FILE_LOCKING extern int fcntl_getlk(struct file *, unsigned int, struct flock *); @@ -1300,7 +1290,6 @@ extern int send_sigurg(struct fown_struct *fown); /* These sb flags are internal to the kernel */ #define SB_SUBMOUNT (1<<26) -#define SB_NOREMOTELOCK (1<<27) #define SB_NOSEC (1<<28) #define SB_BORN (1<<29) #define SB_ACTIVE (1<<30) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index d2a8313fabd7..2840ddcece73 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -134,7 +134,6 @@ struct inodes_stat_t { /* These sb flags are internal to the kernel */ #define MS_SUBMOUNT (1<<26) -#define MS_NOREMOTELOCK (1<<27) #define MS_NOSEC (1<<28) #define MS_BORN (1<<29) #define MS_ACTIVE (1<<30) -- 2.14.3