Skip to content

Rationale for removing .owner = THIS_MODULE in struct file_operations (Linux v6.4+) #348

@visitorckw

Description

@visitorckw

The conditional removal of the explicit .owner = THIS_MODULE initialization in recent module examples was introduced in commit 1c31bac ("Fix Linux v6.5 compatibility"):

static struct file_operations fops = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
    .owner = THIS_MODULE,
#endif
    // ...
};

My Questions:

  1. What is the specific Linux kernel commit that introduced this change, and what is the technical rationale? (Since struct file_operations::owner still exists in the header, I assume the core kernel now automatically handles module usage counting for file operations, making the explicit setting redundant?)

  2. The change was introduced to fix "Linux v6.5 compatibility," but the version check uses < 6.4.0. Could you please clarify the exact version boundary, and whether the condition should potentially be adjusted (e.g., changing < to <= or the version numbers)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions