linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n
@ 2024-02-04 12:32 Jeff Layton
  2024-02-04 23:43 ` Chuck Lever
  2024-02-05 12:10 ` Christian Brauner
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff Layton @ 2024-02-04 12:32 UTC (permalink / raw)
  To: Christian Brauner, Al Viro, Chuck Lever
  Cc: linux-kernel, linux-fsdevel, kernel test robot, Jeff Layton

We recently added several functions to the file locking API. Add stubs
for those functions for when CONFIG_FILE_LOCKING is set to n.

Fixes: 403594111407 ("filelock: add some new helper functions")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402041412.6YvtlflL-lkp@intel.com/
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Just a small follow-on fix for CONFIG_FILE_LOCKING=n builds for the
file_lease split. Christian, it might be best to squash this into
the patch it Fixes.

That said, I'm starting to wonder if we ought to just hardcode
CONFIG_FILE_LOCKING to y. Does anyone ship kernels with it disabled? I
guess maybe people with stripped-down embedded builds might?

Another thought too: "locks_" as a prefix is awfully generic. Might it be
better to rename these new functions with a "filelock_" prefix instead?
That would better distinguish to the casual reader that this is dealing
with a file_lock object. I'm happy to respin the set if that's the
consensus.
---
 include/linux/filelock.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/filelock.h b/include/linux/filelock.h
index 4a5ad26962c1..553d65a88048 100644
--- a/include/linux/filelock.h
+++ b/include/linux/filelock.h
@@ -263,6 +263,27 @@ static inline int fcntl_getlease(struct file *filp)
 	return F_UNLCK;
 }
 
+static inline bool lock_is_unlock(struct file_lock *fl)
+{
+	return false;
+}
+
+static inline bool lock_is_read(struct file_lock *fl)
+{
+	return false;
+}
+
+static inline bool lock_is_write(struct file_lock *fl)
+{
+	return false;
+}
+
+static inline void locks_wake_up(struct file_lock *fl)
+{
+}
+
+#define for_each_file_lock(_fl, _head)	while(false)
+
 static inline void
 locks_free_lock_context(struct inode *inode)
 {

---
base-commit: 1499e59af376949b062cdc039257f811f6c1697f
change-id: 20240204-flsplit3-da666d82b7b4

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n
  2024-02-04 12:32 [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n Jeff Layton
@ 2024-02-04 23:43 ` Chuck Lever
  2024-02-05 12:10 ` Christian Brauner
  1 sibling, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2024-02-04 23:43 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Al Viro, linux-kernel, linux-fsdevel,
	kernel test robot

On Sun, Feb 04, 2024 at 07:32:55AM -0500, Jeff Layton wrote:
> We recently added several functions to the file locking API. Add stubs
> for those functions for when CONFIG_FILE_LOCKING is set to n.
> 
> Fixes: 403594111407 ("filelock: add some new helper functions")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202402041412.6YvtlflL-lkp@intel.com/
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> Just a small follow-on fix for CONFIG_FILE_LOCKING=n builds for the
> file_lease split. Christian, it might be best to squash this into
> the patch it Fixes.
> 
> That said, I'm starting to wonder if we ought to just hardcode
> CONFIG_FILE_LOCKING to y. Does anyone ship kernels with it disabled? I
> guess maybe people with stripped-down embedded builds might?

One thing you might try is building a kernel with both settings
and compare the resulting object sizes.

CONFIG_FILE_LOCKING was added during the git era, actually, so we
have some reasonable archaeology available:

commit bfcd17a6c5529bc37234cfa720a047cf9397bcfc
Author:     Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
AuthorDate: Wed Aug 6 15:12:22 2008 +0200
Commit:     J. Bruce Fields <bfields@fieldses.org>
CommitDate: Mon Sep 29 17:56:57 2008 -0400

    Configure out file locking features
    
    This patch adds the CONFIG_FILE_LOCKING option which allows to remove
    support for advisory locks. With this patch enabled, the flock()
    system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl()
    and NFS support are disabled. These features are not necessarly needed
    on embedded systems. It allows to save ~11 Kb of kernel code and data:
    
       text          data     bss     dec     hex filename
    1125436        118764  212992 1457192  163c28 vmlinux.old
    1114299        118564  212992 1445855  160fdf vmlinux
     -11137    -200       0  -11337   -2C49 +/-
    
    This patch has originally been written by Matt Mackall
    <mpm@selenic.com>, and is part of the Linux Tiny project.


Embedded folks might want to keep CONFIG_FILE_LOCKING.


> Another thought too: "locks_" as a prefix is awfully generic. Might it be
> better to rename these new functions with a "filelock_" prefix instead?
> That would better distinguish to the casual reader that this is dealing
> with a file_lock object. I'm happy to respin the set if that's the
> consensus.

"posix_lock" might be even better, but no-one likes to make function
names longer.


> ---
>  include/linux/filelock.h | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/include/linux/filelock.h b/include/linux/filelock.h
> index 4a5ad26962c1..553d65a88048 100644
> --- a/include/linux/filelock.h
> +++ b/include/linux/filelock.h
> @@ -263,6 +263,27 @@ static inline int fcntl_getlease(struct file *filp)
>  	return F_UNLCK;
>  }
>  
> +static inline bool lock_is_unlock(struct file_lock *fl)
> +{
> +	return false;
> +}
> +
> +static inline bool lock_is_read(struct file_lock *fl)
> +{
> +	return false;
> +}
> +
> +static inline bool lock_is_write(struct file_lock *fl)
> +{
> +	return false;
> +}
> +
> +static inline void locks_wake_up(struct file_lock *fl)
> +{
> +}
> +
> +#define for_each_file_lock(_fl, _head)	while(false)
> +
>  static inline void
>  locks_free_lock_context(struct inode *inode)
>  {
> 
> ---
> base-commit: 1499e59af376949b062cdc039257f811f6c1697f
> change-id: 20240204-flsplit3-da666d82b7b4
> 
> Best regards,
> -- 
> Jeff Layton <jlayton@kernel.org>
> 
> 

-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n
  2024-02-04 12:32 [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n Jeff Layton
  2024-02-04 23:43 ` Chuck Lever
@ 2024-02-05 12:10 ` Christian Brauner
  2024-02-05 12:20   ` Jeff Layton
  1 sibling, 1 reply; 4+ messages in thread
From: Christian Brauner @ 2024-02-05 12:10 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Al Viro, Chuck Lever, linux-kernel, linux-fsdevel,
	kernel test robot

> Another thought too: "locks_" as a prefix is awfully generic. Might it be
> better to rename these new functions with a "filelock_" prefix instead?
> That would better distinguish to the casual reader that this is dealing
> with a file_lock object. I'm happy to respin the set if that's the
> consensus.

If it's just a rename then just point me to a branch I can pull. I don't
think it's worth resending just because you effectively did some variant
of s/lock_*/filelock_*/g

In any case, folded this one.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n
  2024-02-05 12:10 ` Christian Brauner
@ 2024-02-05 12:20   ` Jeff Layton
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2024-02-05 12:20 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Al Viro, Chuck Lever, linux-kernel, linux-fsdevel,
	kernel test robot

On Mon, 2024-02-05 at 13:10 +0100, Christian Brauner wrote:
> > Another thought too: "locks_" as a prefix is awfully generic. Might it be
> > better to rename these new functions with a "filelock_" prefix instead?
> > That would better distinguish to the casual reader that this is dealing
> > with a file_lock object. I'm happy to respin the set if that's the
> > consensus.
> 
> If it's just a rename then just point me to a branch I can pull. I don't
> think it's worth resending just because you effectively did some variant
> of s/lock_*/filelock_*/g
> 
> In any case, folded this one.

Thanks!

I haven't done a rename (yet). I was just trying to feel out whether it
was worthwhile. At this point, I'm thinking I'll just leave them as-is.,
but let me know if anyone has opinions to the contrary.
-- 
Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-05 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-04 12:32 [PATCH] filelock: add stubs for new functions when CONFIG_FILE_LOCKING=n Jeff Layton
2024-02-04 23:43 ` Chuck Lever
2024-02-05 12:10 ` Christian Brauner
2024-02-05 12:20   ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).