ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 4/5] ocfs2: Disallow duplicate entries in the list
Date: Tue, 10 May 2016 12:52:38 -0500	[thread overview]
Message-ID: <1462902759-27084-5-git-send-email-rgoldwyn@suse.de> (raw)
In-Reply-To: <1462902759-27084-1-git-send-email-rgoldwyn@suse.de>

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

A check to make sure we don't have duplicates in the filecheck list.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/ocfs2/filecheck.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
index 0b41967..006d521 100644
--- a/fs/ocfs2/filecheck.c
+++ b/fs/ocfs2/filecheck.c
@@ -217,14 +217,12 @@ ocfs2_filecheck_handle_entry(struct ocfs2_super *osb,
 int ocfs2_filecheck_add_inode(struct ocfs2_super *osb,
 				     unsigned long ino)
 {
-	struct ocfs2_filecheck_entry *entry;
+	struct ocfs2_filecheck_entry *entry, *p;
 	ssize_t ret = 0;
 
 	entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS);
-	if (!entry) {
-		ret = -ENOMEM;
-		goto exit;
-	}
+	if (!entry)
+		return -ENOMEM;
 
 	spin_lock(&osb->fc_lock);
 	if ((osb->fc_size >= osb->fc_max) &&
@@ -244,6 +242,12 @@ int ocfs2_filecheck_add_inode(struct ocfs2_super *osb,
 			 */
 			BUG_ON(!ocfs2_filecheck_erase_entry(osb));
 		}
+		list_for_each_entry(p, &osb->file_check_entries, fe_list)
+			if (p->fe_ino == ino) {
+				ret = -EEXIST;
+				kfree(entry);
+				goto unlock;
+			}
 
 		entry->fe_ino = ino;
 		entry->fe_type = OCFS2_FILECHECK_TYPE_CHK;
@@ -252,11 +256,15 @@ int ocfs2_filecheck_add_inode(struct ocfs2_super *osb,
 		list_add_tail(&entry->fe_list, &osb->file_check_entries);
 		osb->fc_size++;
 	}
+unlock:
 	spin_unlock(&osb->fc_lock);
 
-	if (!ret)
-		ocfs2_filecheck_handle_entry(osb, entry);
+	if (ret)
+		return ret;
 
-exit:
-	return ret;
+	entry->fe_status = ocfs2_filecheck_handle(osb,
+			entry->fe_ino, OCFS2_FI_FLAG_FILECHECK_CHK);
+
+	ocfs2_filecheck_done_entry(osb, entry);
+	return 0;
 }
-- 
2.6.6

  parent reply	other threads:[~2016-05-10 17:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10 17:52 [Ocfs2-devel] [PATCH 0/5] ocfs2: sysfs and cleanup Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 1/5] ocfs2: Provisions for sysfs entries Goldwyn Rodrigues
2016-05-11 10:53   ` Joseph Qi
2016-05-11 12:04     ` Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 2/5] Use the sysfs interface for creating filecheck files Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 3/5] Generate uevents for errors Goldwyn Rodrigues
2016-05-10 17:52 ` Goldwyn Rodrigues [this message]
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 5/5] Fix files when an inode is written in file_fix Goldwyn Rodrigues
2016-05-11  1:58 ` [Ocfs2-devel] [PATCH 0/5] ocfs2: sysfs and cleanup Gang He
  -- strict thread matches above, loose matches on Subject: below --
2016-05-26  3:10 [Ocfs2-devel] [PATCH v2 " Goldwyn Rodrigues
2016-05-26  3:10 ` [Ocfs2-devel] [PATCH 4/5] ocfs2: Disallow duplicate entries in the list Goldwyn Rodrigues
2016-05-30  9:28   ` Gang He

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=1462902759-27084-5-git-send-email-rgoldwyn@suse.de \
    --to=rgoldwyn@suse.de \
    --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).