This patch remove the redundant "i_nlink >= OCFS2_LINK_MAX" check
and add an unlinked directory check.
Singed-off-by: mfasheh
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 0673862..719a8d2 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -643,11 +643,6 @@ static int ocfs2_link(struct dentry *old
goto bail;
}
- if (inode->i_nlink >= OCFS2_LINK_MAX) {
- err = -EMLINK;
- goto bail;
- }
-
handle = ocfs2_alloc_handle(osb);
if (handle == NULL) {
err = -ENOMEM;
@@ -661,6 +656,11 @@ static int ocfs2_link(struct dentry *old
goto bail;
}
+ if (!dir->i_nlink) {
+ err = -ENOENT;
+ goto bail;
+ }
+
err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
dentry->d_name.len);
if (err)
-------------- next part --------------
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 0673862..719a8d2 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -643,11 +643,6 @@ static int ocfs2_link(struct dentry *old
goto bail;
}
- if (inode->i_nlink >= OCFS2_LINK_MAX) {
- err = -EMLINK;
- goto bail;
- }
-
handle = ocfs2_alloc_handle(osb);
if (handle == NULL) {
err = -ENOMEM;
@@ -661,6 +656,11 @@ static int ocfs2_link(struct dentry *old
goto bail;
}
+ if (!dir->i_nlink) {
+ err = -ENOENT;
+ goto bail;
+ }
+
err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
dentry->d_name.len);
if (err)
On Fri, Sep 01, 2006 at 10:27:32AM +0800, Tiger Yang wrote:> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c > index 0673862..719a8d2 100644 > --- a/fs/ocfs2/namei.c > +++ b/fs/ocfs2/namei.c > @@ -643,11 +643,6 @@ static int ocfs2_link(struct dentry *old > goto bail; > } > > - if (inode->i_nlink >= OCFS2_LINK_MAX) { > - err = -EMLINK; > - goto bail; > - } > -Why is this redundant? Is someone doing it for us? I see we check the fe->i_links_count below, but that's after the expense of a cluster lock. Don't we save some effort here?> @@ -661,6 +656,11 @@ static int ocfs2_link(struct dentry *old > goto bail; > } > > + if (!dir->i_nlink) { > + err = -ENOENT; > + goto bail; > + } > +And what does this do? If a directory...oh, wait, is this to check for a directory that's going away? Can this actually happen? I'd think that the VFS would protect it. Joel -- "Well-timed silence hath more eloquence than speech." - Martin Fraquhar Tupper Joel Becker Principal Software Developer Oracle E-mail: joel.becker@oracle.com Phone: (650) 506-8127
Hi Tiger, On Fri, Sep 01, 2006 at 10:27:32AM +0800, Tiger Yang wrote:> This patch remove the redundant "i_nlink >= OCFS2_LINK_MAX" check > and add an unlinked directory check.Ok, this looks good - thanks. --Mark -- Mark Fasheh Senior Software Developer, Oracle mark.fasheh@oracle.com
Maybe Matching Threads
- [PATCH 0/7] ocfs2: Directory indexing support
- [git patches] Ocfs2 updates for 2.6.30
- [PATCH 1/1] OCFS2: add nlink check in ocfs2_inode_revalidate()
- [PATCH V2] ocfs2: need rollback when journal_access failed in ocfs2_orphan_add()
- ocfs2_check_dir_for_entry:2119 ERROR: status = -17