2022-11-11 01:33:19

by Ahelenia Ziemiańska

[permalink] [raw]
Subject: [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC

We have largely moved away from this approach, and we have better
debugging instrumentation nowadays: kill it.

Link: https://lore.kernel.org/linux-doc/[email protected]/
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
---
Documentation/process/magic-number.rst | 1 -
Documentation/translations/it_IT/process/magic-number.rst | 1 -
Documentation/translations/zh_CN/process/magic-number.rst | 1 -
Documentation/translations/zh_TW/process/magic-number.rst | 1 -
fs/fcntl.c | 6 ------
include/linux/fs.h | 3 ---
6 files changed, 13 deletions(-)

diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
index e59c707ec785..6e432917a5a8 100644
--- a/Documentation/process/magic-number.rst
+++ b/Documentation/process/magic-number.rst
@@ -68,6 +68,5 @@ Changelog::
===================== ================ ======================== ==========================================
Magic Name Number Structure File
===================== ================ ======================== ==========================================
-FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
index 37a539867b6f..7d4c117ac626 100644
--- a/Documentation/translations/it_IT/process/magic-number.rst
+++ b/Documentation/translations/it_IT/process/magic-number.rst
@@ -74,6 +74,5 @@ Registro dei cambiamenti::
===================== ================ ======================== ==========================================
Nome magico Numero Struttura File
===================== ================ ======================== ==========================================
-FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
index 8a3a3e872c52..c17e3f20440a 100644
--- a/Documentation/translations/zh_CN/process/magic-number.rst
+++ b/Documentation/translations/zh_CN/process/magic-number.rst
@@ -57,6 +57,5 @@ Linux 魔术数
===================== ================ ======================== ==========================================
魔术数名 数字 结构 文件
===================== ================ ======================== ==========================================
-FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
===================== ================ ======================== ==========================================
diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
index 7ace7834f7f9..e2eeb74e7192 100644
--- a/Documentation/translations/zh_TW/process/magic-number.rst
+++ b/Documentation/translations/zh_TW/process/magic-number.rst
@@ -60,6 +60,5 @@ Linux 魔術數
===================== ================ ======================== ==========================================
魔術數名 數字 結構 文件
===================== ================ ======================== ==========================================
-FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
===================== ================ ======================== ==========================================
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 146c9ab0cd4b..e366a3804108 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -924,7 +924,6 @@ struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasy
}

rwlock_init(&new->fa_lock);
- new->magic = FASYNC_MAGIC;
new->fa_file = filp;
new->fa_fd = fd;
new->fa_next = *fapp;
@@ -988,11 +987,6 @@ static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
struct fown_struct *fown;
unsigned long flags;

- if (fa->magic != FASYNC_MAGIC) {
- printk(KERN_ERR "kill_fasync: bad magic number in "
- "fasync_struct!\n");
- return;
- }
read_lock_irqsave(&fa->fa_lock, flags);
if (fa->fa_file) {
fown = &fa->fa_file->f_owner;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e654435f1651..acfd5db5341a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1345,15 +1345,12 @@ static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)

struct fasync_struct {
rwlock_t fa_lock;
- int magic;
int fa_fd;
struct fasync_struct *fa_next; /* singly linked list */
struct file *fa_file;
struct rcu_head fa_rcu;
};

-#define FASYNC_MAGIC 0x4601
-
/* SMP safe fasync helpers: */
extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);
--
2.30.2


Attachments:
(No filename) (5.69 kB)
signature.asc (849.00 B)
Download all attachments

2022-11-11 10:39:40

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH v3 13/15] fcntl: remove FASYNC_MAGIC

On Fri, 2022-11-11 at 02:14 +0100, Ahelenia Ziemiańska wrote:
> We have largely moved away from this approach, and we have better
> debugging instrumentation nowadays: kill it.
>
> Link: https://lore.kernel.org/linux-doc/[email protected]/
> Signed-off-by: Ahelenia Ziemiańska <[email protected]>
> ---
> Documentation/process/magic-number.rst | 1 -
> Documentation/translations/it_IT/process/magic-number.rst | 1 -
> Documentation/translations/zh_CN/process/magic-number.rst | 1 -
> Documentation/translations/zh_TW/process/magic-number.rst | 1 -
> fs/fcntl.c | 6 ------
> include/linux/fs.h | 3 ---
> 6 files changed, 13 deletions(-)
>
> diff --git a/Documentation/process/magic-number.rst b/Documentation/process/magic-number.rst
> index e59c707ec785..6e432917a5a8 100644
> --- a/Documentation/process/magic-number.rst
> +++ b/Documentation/process/magic-number.rst
> @@ -68,6 +68,5 @@ Changelog::
> ===================== ================ ======================== ==========================================
> Magic Name Number Structure File
> ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
> ===================== ================ ======================== ==========================================
> diff --git a/Documentation/translations/it_IT/process/magic-number.rst b/Documentation/translations/it_IT/process/magic-number.rst
> index 37a539867b6f..7d4c117ac626 100644
> --- a/Documentation/translations/it_IT/process/magic-number.rst
> +++ b/Documentation/translations/it_IT/process/magic-number.rst
> @@ -74,6 +74,5 @@ Registro dei cambiamenti::
> ===================== ================ ======================== ==========================================
> Nome magico Numero Struttura File
> ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
> ===================== ================ ======================== ==========================================
> diff --git a/Documentation/translations/zh_CN/process/magic-number.rst b/Documentation/translations/zh_CN/process/magic-number.rst
> index 8a3a3e872c52..c17e3f20440a 100644
> --- a/Documentation/translations/zh_CN/process/magic-number.rst
> +++ b/Documentation/translations/zh_CN/process/magic-number.rst
> @@ -57,6 +57,5 @@ Linux 魔术数
> ===================== ================ ======================== ==========================================
> 魔术数名 数字 结构 文件
> ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
> ===================== ================ ======================== ==========================================
> diff --git a/Documentation/translations/zh_TW/process/magic-number.rst b/Documentation/translations/zh_TW/process/magic-number.rst
> index 7ace7834f7f9..e2eeb74e7192 100644
> --- a/Documentation/translations/zh_TW/process/magic-number.rst
> +++ b/Documentation/translations/zh_TW/process/magic-number.rst
> @@ -60,6 +60,5 @@ Linux 魔術數
> ===================== ================ ======================== ==========================================
> 魔術數名 數字 結構 文件
> ===================== ================ ======================== ==========================================
> -FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h``
> CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c``
> ===================== ================ ======================== ==========================================
> diff --git a/fs/fcntl.c b/fs/fcntl.c
> index 146c9ab0cd4b..e366a3804108 100644
> --- a/fs/fcntl.c
> +++ b/fs/fcntl.c
> @@ -924,7 +924,6 @@ struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasy
> }
>
> rwlock_init(&new->fa_lock);
> - new->magic = FASYNC_MAGIC;
> new->fa_file = filp;
> new->fa_fd = fd;
> new->fa_next = *fapp;
> @@ -988,11 +987,6 @@ static void kill_fasync_rcu(struct fasync_struct *fa, int sig, int band)
> struct fown_struct *fown;
> unsigned long flags;
>
> - if (fa->magic != FASYNC_MAGIC) {
> - printk(KERN_ERR "kill_fasync: bad magic number in "
> - "fasync_struct!\n");
> - return;
> - }
> read_lock_irqsave(&fa->fa_lock, flags);
> if (fa->fa_file) {
> fown = &fa->fa_file->f_owner;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index e654435f1651..acfd5db5341a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1345,15 +1345,12 @@ static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
>
> struct fasync_struct {
> rwlock_t fa_lock;
> - int magic;
> int fa_fd;
> struct fasync_struct *fa_next; /* singly linked list */
> struct file *fa_file;
> struct rcu_head fa_rcu;
> };
>
> -#define FASYNC_MAGIC 0x4601
> -
> /* SMP safe fasync helpers: */
> extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
> extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);

Reviewed-by: Jeff Layton <[email protected]>