Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp385435imm; Thu, 26 Jul 2018 05:29:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcA7dloUG/vq8QOveMvPS7pc/ce5ImuzY1PHOc27inC4NDvvo8qfxDBU6nNjEvwi1P+xPQ4 X-Received: by 2002:a62:fd06:: with SMTP id p6-v6mr1864461pfh.167.1532608159199; Thu, 26 Jul 2018 05:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532608159; cv=none; d=google.com; s=arc-20160816; b=k9r9gGhtWwb0vZtpu5aaOOoWT4fxZeZrNdIEuZe2uND9VKFKKWI5m65GabTsZAfgfy aWEaPPBVHRs+qSuy0mNbDTZo8YThOw5nJlDydtFnkjkxZMbB2OCAk7swnOri5p3rymfR dGFHyYC3Y1rUEefWpEoFghJWQDXxI4YP4dz5MCI+iE6rO5TqSwpMONp/onSA7aRUhBdf mTk2AZmLcwyn4pKJYn6rV8IJAp3tVlEQ3JXQN88HFv8jDrNiiE3Ew4SH7UVqO+ux6eSh h6Rw3Mydu6WV5MwU14m4PoIUiAVnjlazP7Se95nFfSTbuaIDLBSA34/vvviiSc0san7C o02w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=OtIO33+BzhxBDgOt2cYWdwNiTIaXjrJLFDBWGm6ZWTg=; b=HRAqDvilccuRNZVkXZqXC7WF/mjgAVbdR5uOj5bDdXZ4uhDUTdQIqsyUR/rDog8/NK 2KrOkUe0/KeruF+HlNGI//zZMqwpjjt1u70rjWuSk4htD9/sUS5V3wZ6gFMB1eGVoQzW 1oeTDWHAnQ4VnA7+IPwzP1oac2vLmmkH2PPuCN4maaa7oEYi4fr2AmKGhbR0dw9571i4 SFlQlxEQg01p3cWvhUpuMHFfsVpNKvrci5LZ8duHCOWLtJMBa+gRez8qH1r14ETd1/NR MDOrie9g7/+TBaRsVguRMAtH4LD7Z6FVNekuLvRIK6YgsRw+e3vQLWbl87o0eSlktvPi cORg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z68-v6si1265928pfz.163.2018.07.26.05.29.04; Thu, 26 Jul 2018 05:29:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731720AbeGZNo3 (ORCPT + 99 others); Thu, 26 Jul 2018 09:44:29 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9727 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729962AbeGZNo3 (ORCPT ); Thu, 26 Jul 2018 09:44:29 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3166A7D7C5EE1; Thu, 26 Jul 2018 20:27:47 +0800 (CST) Received: from szvp000100637.huawei.com (10.162.55.131) by smtp.huawei.com (10.3.19.208) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 26 Jul 2018 20:27:43 +0800 From: Gao Xiang To: Greg Kroah-Hartman , CC: , , , , , , , , Gao Xiang Subject: [PATCH 20/25] staging: erofs: introduce superblock registration Date: Thu, 26 Jul 2018 20:22:03 +0800 Message-ID: <1532607728-103372-21-git-send-email-gaoxiang25@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532607728-103372-1-git-send-email-gaoxiang25@huawei.com> References: <1527764767-22190-1-git-send-email-gaoxiang25@huawei.com> <1532607728-103372-1-git-send-email-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.162.55.131] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to introducing shrinker solution for erofs, let's manage all mounted erofs instances at first. Signed-off-by: Gao Xiang --- drivers/staging/erofs/internal.h | 6 ++++++ drivers/staging/erofs/super.c | 4 ++++ drivers/staging/erofs/utils.c | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index e61d417..18e7b9c 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -64,6 +64,9 @@ struct erofs_fault_info { typedef u64 erofs_nid_t; struct erofs_sb_info { + /* list for all registered superblocks, mainly for shrinker */ + struct list_head list; + u32 blocks; u32 meta_blkaddr; #ifdef CONFIG_EROFS_FS_XATTR @@ -410,6 +413,9 @@ static inline void erofs_vunmap(const void *mem, unsigned int count) /* utils.c */ extern struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp); +extern void erofs_register_super(struct super_block *sb); +extern void erofs_unregister_super(struct super_block *sb); + #ifndef lru_to_page #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) #endif diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 054375d..f455d71 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -326,6 +326,8 @@ static int erofs_read_super(struct super_block *sb, snprintf(sbi->dev_name, PATH_MAX, "%s", dev_name); sbi->dev_name[PATH_MAX - 1] = '\0'; + erofs_register_super(sb); + /* * We already have a positive dentry, which was instantiated * by d_make_root. Just need to d_rehash it. @@ -373,6 +375,8 @@ static void erofs_put_super(struct super_block *sb) infoln("unmounted for %s", sbi->dev_name); __putname(sbi->dev_name); + erofs_unregister_super(sb); + kfree(sbi); sb->s_fs_info = NULL; } diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index 3dec4f8..6748def 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -29,3 +29,20 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) return page; } +static DEFINE_MUTEX(erofs_sb_list_lock); +static LIST_HEAD(erofs_sb_list); + +void erofs_register_super(struct super_block *sb) +{ + mutex_lock(&erofs_sb_list_lock); + list_add(&EROFS_SB(sb)->list, &erofs_sb_list); + mutex_unlock(&erofs_sb_list_lock); +} + +void erofs_unregister_super(struct super_block *sb) +{ + mutex_lock(&erofs_sb_list_lock); + list_del(&EROFS_SB(sb)->list); + mutex_unlock(&erofs_sb_list_lock); +} + -- 1.9.1