linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gang He <ghe@suse.com>
To: mfasheh@versity.com, jlbec@evilplan.org
Cc: Gang He <ghe@suse.com>,
	linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com,
	akpm@linux-foundation.org
Subject: [PATCH v2 4/4] ocfs2: add duplicative ino number check
Date: Wed, 21 Dec 2016 16:21:01 +0800	[thread overview]
Message-ID: <1482308461-12964-5-git-send-email-ghe@suse.com> (raw)
In-Reply-To: <1482308461-12964-1-git-send-email-ghe@suse.com>

Add duplicative ino number check, to avoid adding a file into the
file check list when this file is being checked.

Signed-off-by: Gang He <ghe@suse.com>
---
 fs/ocfs2/filecheck.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
index a94c531..f65f2b2 100644
--- a/fs/ocfs2/filecheck.c
+++ b/fs/ocfs2/filecheck.c
@@ -354,6 +354,22 @@ static ssize_t ocfs2_filecheck_attr_show(struct kobject *kobj,
 }
 
 static inline int
+ocfs2_filecheck_is_dup_entry(struct ocfs2_filecheck_sysfs_entry *ent,
+				unsigned long ino)
+{
+	struct ocfs2_filecheck_entry *p;
+
+	list_for_each_entry(p, &ent->fs_fcheck->fc_head, fe_list) {
+		if (!p->fe_done) {
+			if (p->fe_ino == ino)
+				return 1;
+		}
+	}
+
+	return 0;
+}
+
+static inline int
 ocfs2_filecheck_erase_entry(struct ocfs2_filecheck_sysfs_entry *ent)
 {
 	struct ocfs2_filecheck_entry *p;
@@ -467,7 +483,10 @@ static ssize_t ocfs2_filecheck_attr_store(struct kobject *kobj,
 	}
 
 	spin_lock(&ent->fs_fcheck->fc_lock);
-	if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) &&
+	if (ocfs2_filecheck_is_dup_entry(ent, args.fa_ino)) {
+		ret = -EEXIST;
+		kfree(entry);
+	} else if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) &&
 		(ent->fs_fcheck->fc_done == 0)) {
 		mlog(ML_NOTICE,
 		"Cannot do more file check "
-- 
1.8.5.6

      parent reply	other threads:[~2016-12-21  8:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21  8:20 [PATCH v2 0/4] ocfs2: use kobject for online file check Gang He
2016-12-21  8:20 ` [PATCH v2 1/4] ocfs2: move some definitions to header file Gang He
2016-12-21  8:20 ` [PATCH v2 2/4] ocfs2: fix some small problems Gang He
2016-12-28 22:34   ` Mark Fasheh
2016-12-29  2:54     ` Gang He
2016-12-21  8:21 ` [PATCH v2 3/4] ocfs2: add kobject for online file check Gang He
2016-12-21  8:21 ` Gang He [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482308461-12964-5-git-send-email-ghe@suse.com \
    --to=ghe@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfasheh@versity.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).