Skip to contentSkip to conversation

Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

PATCH New Tristan Ye 3 participants 11 messages Mar 23, 2010 – Mar 26, 2010 OCFS2

lore
Share & tools
lore

Tristan Ye

author
#0 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Fast symlink can be treated the same way as inline file for truncating and hole punching, since the mechanism is quite simliar per se.

---
 fs/ocfs2/alloc.c |   18 ++++++++++++++----
 fs/ocfs2/file.c  |    7 +++++--
 2 files changed, 19 insertions(+), 6 deletions(-)
fs/ocfs2/alloc.c +14 -4
index 9f8bd91..f13ce3e 100644
@@ -50,6 +50,7 @@
 #include "uptodate.h"
 #include "xattr.h"
 #include "refcounttree.h"
+#include "symlink.h"
 
 #include "buffer_head_io.h"
 
@@ -7668,6 +7669,10 @@ bail:
 
 /*
  * 'start' is inclusive, 'end' is not.
+ *
+ * The name ocfs2_truncate_inline() may be misleading a little bit, since
+ * it handles truncating for fast symlink as well, cause they actually will
+ * be doing one thing per se.
  */
 int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
 			  unsigned int start, unsigned int end, int trunc)
@@ -7684,12 +7689,14 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
 
 	BUG_ON(start >= end);
 
-	if (!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) ||
+	if ((!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) ||
 	    !(le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL) ||
-	    !ocfs2_supports_inline_data(osb)) {
+	    !ocfs2_supports_inline_data(osb)) &&
+	    (!ocfs2_inode_is_fast_symlink(inode))) {
 		ocfs2_error(inode->i_sb,
 			    "Inline data flags for inode %llu don't agree! "
-			    "Disk: 0x%x, Memory: 0x%x, Superblock: 0x%x\n",
+			    "Disk: 0x%x, Memory: 0x%x, Superblock: 0x%x, "
+			    "and it's not a fast symlink as well.\n",
 			    (unsigned long long)OCFS2_I(inode)->ip_blkno,
 			    le16_to_cpu(di->i_dyn_features),
 			    OCFS2_I(inode)->ip_dyn_features,
@@ -7713,7 +7720,10 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
 	}
 
 	numbytes = end - start;
-	memset(idata->id_data + start, 0, numbytes);
+	if (ocfs2_inode_is_fast_symlink(inode))
+		memset(di->id2.i_symlink + start, 0, numbytes);
+	else
+		memset(idata->id_data + start, 0, numbytes);
 
 	/*
 	 * No need to worry about the data page here - it's been
fs/ocfs2/file.c +5 -2
index 17947dc..290a3b0 100644
@@ -60,6 +60,7 @@
 #include "acl.h"
 #include "quota.h"
 #include "refcounttree.h"
+#include "symlink.h"
 
 #include "buffer_head_io.h"
 
@@ -498,7 +499,8 @@ static int ocfs2_truncate_file(struct inode *inode,
 	unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1);
 	truncate_inode_pages(inode->i_mapping, new_i_size);
 
-	if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
+	if ((OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) ||
+	    (ocfs2_inode_is_fast_symlink(inode))) {
 		status = ocfs2_truncate_inline(inode, di_bh, new_i_size,
 					       i_size_read(inode), 1);
 		if (status)
@@ -1450,7 +1452,8 @@ static int ocfs2_remove_inode_range(struct inode *inode,
 	if (byte_len == 0)
 		return 0;
 
-	if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
+	if ((OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) ||
+	    (ocfs2_inode_is_fast_symlink(inode))) {
 		ret = ocfs2_truncate_inline(inode, di_bh, byte_start,
 					    byte_start + byte_len, 0);
 		if (ret) {
Signature · 1 line
1.5.5
#1 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 4 lines · Tristan Ye

Fast symlink can be treated the same way as inline file for truncating and hole punching, since the mechanism is quite simliar per se.

The patch looks good, with perhaps a bit over-zealous
parentheses ;-) Is this fixing a bug someone has hit?

Joel

Signature · 9 lines
"In a crisis, don't hide behind anything or anybody. They're going
 to find you anyway."
	- Paul "Bear" Bryant

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
author
#2 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 8 lines · Joel Becker
Quoted 4 lines · Tristan Ye

Fast symlink can be treated the same way as inline file for truncating and hole punching, since the mechanism is quite simliar per se.

The patch looks good, with perhaps a bit over-zealous
parentheses ;-) Is this fixing a bug someone has hit?

Not exactly,

Sunil reported such a bug from userspace in libocfs2, I suddenly realised that we could also do the same in fs.

Tristan.

Quoted 4 lines

Joel

#3 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 7 lines · tristan
Quoted 6 lines · Joel Becker
Quoted 4 lines · Tristan Ye

Fast symlink can be treated the same way as inline file for truncating and hole punching, since the mechanism is quite simliar per se.

Quoted 7 lines
Quoted 2 lines

The patch looks good, with perhaps a bit over-zealous
parentheses ;-) Is this fixing a bug someone has hit?

Not exactly,

Sunil reported such a bug from userspace in libocfs2, I suddenly realised that we could also do the same in fs.

The difference is that we never call the truncate code for fast
symlinks or inline data in the kernel. We do in libocfs2.

Joel

Signature · 9 lines
"If you took all of the grains of sand in the world, and lined
 them up end to end in a row, you'd be working for the government!"
	- Mr. Interesting

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
author
#4 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 9 lines · Joel Becker
Quoted 8 lines · tristan
Quoted 7 lines · Joel Becker
Quoted 4 lines · Tristan Ye

Fast symlink can be treated the same way as inline file for truncating and hole punching, since the mechanism is quite simliar per se.

The patch looks good, with perhaps a bit over-zealous
parentheses ;-) Is this fixing a bug someone has hit?

Quoted 7 lines
Quoted 4 lines

Not exactly,

Sunil reported such a bug from userspace in libocfs2, I suddenly realised that we could also do the same in fs.

The difference is that we never call the truncate code for fast
symlinks or inline data in the kernel. We do in libocfs2.

Really?

Truncating for inline data is common I guess, for symlink, we may lack of method to truncate it from userspace via ftruncate(2).

But it's ok to be there, right?

Tristan.

Quoted 3 lines

Joel

#5 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 10 lines · tristan
Quoted 2 lines · Joel Becker

The difference is that we never call the truncate code for fast
symlinks or inline data in the kernel. We do in libocfs2.

Really?

Truncating for inline data is common I guess, for symlink, we may lack of method to truncate it from userspace via ftruncate(2).

But it's ok to be there, right?

It's not OK to be there. The truncate system call will error if
it is not a regular file. Same with OCFS2_IOC_UNRESVP. Thus no symlink can get there. ocfs2_truncate_for_delete() checks i_clusters before calling the real truncate code. Thus it avoids fast symlinks and inline data.

Joel

Signature · 11 lines
"Too much walking shoes worn thin.
 Too much trippin' and my soul's worn thin.
 Time to catch a ride it leaves today
 Her name is what it means.
 Too much walking shoes worn thin."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
author
#6 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 9 lines · Joel Becker
Quoted 8 lines · tristan
Quoted 2 lines · Joel Becker

The difference is that we never call the truncate code for fast
symlinks or inline data in the kernel. We do in libocfs2.

Really?

Truncating for inline data is common I guess, for symlink, we may lack of method to truncate it from userspace via ftruncate(2).

Quoted 7 lines
Quoted 1 line

But it's ok to be there, right?

It's not OK to be there. The truncate system call will error if
it is not a regular file. Same with OCFS2_IOC_UNRESVP. Thus no symlink can get there. ocfs2_truncate_for_delete() checks i_clusters before calling the real truncate code. Thus it avoids fast symlinks and inline data.

Joel,

I agreed with your point on the fact that truncating for fast symlink may be meaningless, since sys_truncate() will block all none-regular files. while it does make sense for inline data, see ocfs2_truncate_inline(), which was used to deal with inline file separately. that's the way we're treating inline file when doing truncating, how did you say we avoid this? that makes me confused.

Tristan.

Quoted 3 lines

Joel

#7 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 6 lines · tristan
Quoted 5 lines

It's not OK to be there. The truncate system call will error if
it is not a regular file. Same with OCFS2_IOC_UNRESVP. Thus no symlink can get there. ocfs2_truncate_for_delete() checks i_clusters before calling the real truncate code. Thus it avoids fast symlinks and inline data.

Quoted 8 lines

Joel,

I agreed with your point on the fact that truncating for fast symlink may be meaningless, since sys_truncate() will block all none-regular files. while it does make sense for inline data, see ocfs2_truncate_inline(), which was used to deal with inline file separately. that's the way we're treating inline file when doing truncating, how did you say we avoid this? that makes me confused.

For inline data, we shortcut into ocfs2_truncate_inline() and
never go into the meaty truncate code. That's all I meant.

Joel

Signature · 8 lines
"Reality is merely an illusion, albeit a very persistent one."
        - Albert Einstien

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#8 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

In reply to tristan
Quoted 6 lines · tristan
Quoted 6 lines
Quoted 5 lines

Not exactly,

Sunil reported such a bug from userspace in libocfs2, I suddenly realised that we could also do the same in fs.

I did not see the patch for libocfs2? Is it in the pipeline or did I miss it?

author
#9 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

Quoted 10 lines · Sunil Mushran
Quoted 6 lines · tristan
Quoted 6 lines
Quoted 5 lines

Not exactly,

Sunil reported such a bug from userspace in libocfs2, I suddenly realised that we could also do the same in fs.

I did not see the patch for libocfs2? Is it in the pipeline or did I miss it?

Oh,

I did send it along with 'setting dtime' patch, let me forward the patch to you.

Tristan.

author
#10 lore raw

PATCH 1/1 Ocfs2: Teach truncating and punching-hole codes to handle fastsymlink.

In reply to Joel Becker
Quoted 8 lines · Joel Becker
Quoted 4 lines · Tristan Ye

Fast symlink can be treated the same way as inline file for truncating and hole punching, since the mechanism is quite simliar per se.

The patch looks good, with perhaps a bit over-zealous
parentheses ;-) Is this fixing a bug someone has hit?

Joel,

You're right, there are some parentheses abuse somewhere, I'll simplify them.

Quoted 4 lines

Joel