* [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree
@ 2013-06-13 17:04 Mark Tinguely
2013-06-13 17:50 ` Mark Tinguely
2013-06-14 2:17 ` Dave Chinner
0 siblings, 2 replies; 5+ messages in thread
From: Mark Tinguely @ 2013-06-13 17:04 UTC (permalink / raw)
To: xfs
[-- Attachment #1: v3-xfs-fix-assert-in-xfs_ifree.patch --]
[-- Type: text/plain, Size: 4213 bytes --]
Adding an extended attribute to a symbolic link can force that
link to an remote extent. xfs_inactive() incorrectly assumes
that any symbolic link small enough to be in the inode core
is incore, resulting in the remote extent to not be removed.
xfs_ifree() will assert on presence of this leaked remote extent.
Signed-off-by: Mark Tinguely <tinguely@sgi.com>
---
fs/xfs/xfs_symlink.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
fs/xfs/xfs_symlink.h | 2 +-
fs/xfs/xfs_trace.h | 2 ++
fs/xfs/xfs_vnodeops.c | 15 +++------------
4 files changed, 53 insertions(+), 15 deletions(-)
Index: b/fs/xfs/xfs_symlink.c
===================================================================
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -585,7 +585,7 @@ xfs_symlink(
/*
* Free a symlink that has blocks associated with it.
*/
-int
+STATIC int
xfs_inactive_symlink_rmt(
xfs_inode_t *ip,
xfs_trans_t **tpp)
@@ -606,7 +606,7 @@ xfs_inactive_symlink_rmt(
tp = *tpp;
mp = ip->i_mount;
- ASSERT(ip->i_d.di_size > XFS_IFORK_DSIZE(ip));
+ ASSERT(ip->i_df.if_flags & XFS_IFEXTENTS);
/*
* We're freeing a symlink that has some
* blocks allocated to it. Free the
@@ -720,3 +720,48 @@ xfs_inactive_symlink_rmt(
error0:
return error;
}
+
+/*
+ * xfs_inactive_symlink - free a symlink
+ */
+int
+xfs_inactive_symlink(
+ struct xfs_inode *ip,
+ struct xfs_trans **tp)
+{
+ struct xfs_mount *mp = ip->i_mount;
+ xfs_fsize_t pathlen;
+
+ trace_xfs_readlink(ip);
+
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
+
+ if (XFS_FORCED_SHUTDOWN(mp))
+ return XFS_ERROR(EIO);
+
+ /*
+ * Zero length symlinks _can_ exist.
+ */
+ pathlen = ip->i_d.di_size;
+ if (!pathlen)
+ return 0;
+
+ if (pathlen < 0 || pathlen > MAXPATHLEN) {
+ xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)",
+ __func__, (unsigned long long) ip->i_ino,
+ (long long) pathlen);
+ ASSERT(0);
+ return XFS_ERROR(EFSCORRUPTED);
+ }
+
+ if (ip->i_df.if_flags & XFS_IFINLINE) {
+ if (ip->i_df.if_bytes > 0)
+ xfs_idata_realloc(ip, -(ip->i_df.if_bytes),
+ XFS_DATA_FORK);
+ ASSERT(ip->i_df.if_bytes == 0);
+ return 0;
+ }
+
+ /* remove the remote symlink */
+ return(xfs_inactive_symlink_rmt(ip, tp));
+}
Index: b/fs/xfs/xfs_symlink.h
===================================================================
--- a/fs/xfs/xfs_symlink.h
+++ b/fs/xfs/xfs_symlink.h
@@ -60,7 +60,7 @@ extern const struct xfs_buf_ops xfs_syml
int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
const char *target_path, umode_t mode, struct xfs_inode **ipp);
int xfs_readlink(struct xfs_inode *ip, char *link);
-int xfs_inactive_symlink_rmt(struct xfs_inode *ip, struct xfs_trans **tpp);
+int xfs_inactive_symlink(struct xfs_inode *ip, struct xfs_trans **tpp);
#endif /* __KERNEL__ */
#endif /* __XFS_SYMLINK_H */
Index: b/fs/xfs/xfs_trace.h
===================================================================
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -594,6 +594,8 @@ DEFINE_INODE_EVENT(xfs_inode_set_eofbloc
DEFINE_INODE_EVENT(xfs_inode_clear_eofblocks_tag);
DEFINE_INODE_EVENT(xfs_inode_free_eofblocks_invalid);
+DEFINE_INODE_EVENT(xfs_symlink_inactive);
+
DECLARE_EVENT_CLASS(xfs_iref_class,
TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip),
TP_ARGS(ip, caller_ip),
Index: b/fs/xfs/xfs_vnodeops.c
===================================================================
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -322,18 +322,9 @@ xfs_inactive(
xfs_trans_ijoin(tp, ip, 0);
if (S_ISLNK(ip->i_d.di_mode)) {
- /*
- * Zero length symlinks _can_ exist.
- */
- if (ip->i_d.di_size > XFS_IFORK_DSIZE(ip)) {
- error = xfs_inactive_symlink_rmt(ip, &tp);
- if (error)
- goto out_cancel;
- } else if (ip->i_df.if_bytes > 0) {
- xfs_idata_realloc(ip, -(ip->i_df.if_bytes),
- XFS_DATA_FORK);
- ASSERT(ip->i_df.if_bytes == 0);
- }
+ error = xfs_inactive_symlink(ip, &tp);
+ if (error)
+ goto out_cancel;
} else if (truncate) {
ip->i_d.di_size = 0;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree
2013-06-13 17:04 [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree Mark Tinguely
@ 2013-06-13 17:50 ` Mark Tinguely
2013-06-13 17:53 ` Mark Tinguely
2013-06-14 2:17 ` Dave Chinner
1 sibling, 1 reply; 5+ messages in thread
From: Mark Tinguely @ 2013-06-13 17:50 UTC (permalink / raw)
To: xfs
On 06/13/13 12:04, Mark Tinguely wrote:
> race_xfs_readlink(ip);
> +
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree
2013-06-13 17:50 ` Mark Tinguely
@ 2013-06-13 17:53 ` Mark Tinguely
0 siblings, 0 replies; 5+ messages in thread
From: Mark Tinguely @ 2013-06-13 17:53 UTC (permalink / raw)
To: xfs
On 06/13/13 12:50, Mark Tinguely wrote:
> On 06/13/13 12:04, Mark Tinguely wrote:
>> race_xfs_readlink(ip);
>> +
>
Augh, one of those days - oops I got the wrong trace in this version of
the patch... should be trace_xfs_symlink_inactive(ip) added in xfs_trace.h
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree
2013-06-13 17:04 [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree Mark Tinguely
2013-06-13 17:50 ` Mark Tinguely
@ 2013-06-14 2:17 ` Dave Chinner
2013-06-14 13:30 ` Mark Tinguely
1 sibling, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2013-06-14 2:17 UTC (permalink / raw)
To: Mark Tinguely; +Cc: xfs
On Thu, Jun 13, 2013 at 12:04:49PM -0500, Mark Tinguely wrote:
> Adding an extended attribute to a symbolic link can force that
> link to an remote extent. xfs_inactive() incorrectly assumes
> that any symbolic link small enough to be in the inode core
> is incore, resulting in the remote extent to not be removed.
> xfs_ifree() will assert on presence of this leaked remote extent.
>
> Signed-off-by: Mark Tinguely <tinguely@sgi.com>
.....
> +/*
> + * xfs_inactive_symlink - free a symlink
> + */
> +int
> +xfs_inactive_symlink(
> + struct xfs_inode *ip,
> + struct xfs_trans **tp)
> +{
> + struct xfs_mount *mp = ip->i_mount;
> + xfs_fsize_t pathlen;
int will do here - it can't be more than MAXPATHLEN = 1024, and this
gets rid of the casts in the error print.
> +
> + trace_xfs_readlink(ip);
trace_xfs_inactive_symlink, as you mentioned ;)
> +
> + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
> +
> + if (XFS_FORCED_SHUTDOWN(mp))
> + return XFS_ERROR(EIO);
> +
> + /*
> + * Zero length symlinks _can_ exist.
> + */
> + pathlen = ip->i_d.di_size;
> + if (!pathlen)
> + return 0;
> +
> + if (pathlen < 0 || pathlen > MAXPATHLEN) {
> + xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)",
> + __func__, (unsigned long long) ip->i_ino,
^ whitespace
> + (long long) pathlen);
Can we change this to a hex-based inode number (much easier to read)
and the pathlen cast can go away if you use an int. i.e.:
xfs_alert(mp, "%s: inode (0x%llx) bad symlink length (%d)",
__func__, (unsigned long long)ip->i_ino, pathlen);
> + ASSERT(0);
> + return XFS_ERROR(EFSCORRUPTED);
> + }
> +
> + if (ip->i_df.if_flags & XFS_IFINLINE) {
> + if (ip->i_df.if_bytes > 0)
> + xfs_idata_realloc(ip, -(ip->i_df.if_bytes),
> + XFS_DATA_FORK);
> + ASSERT(ip->i_df.if_bytes == 0);
> + return 0;
> + }
> +
> + /* remove the remote symlink */
> + return(xfs_inactive_symlink_rmt(ip, tp));
And no () around xfs_inactive_symlink_rmt().
> +}
> Index: b/fs/xfs/xfs_symlink.h
> ===================================================================
> --- a/fs/xfs/xfs_symlink.h
> +++ b/fs/xfs/xfs_symlink.h
> @@ -60,7 +60,7 @@ extern const struct xfs_buf_ops xfs_syml
> int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
> const char *target_path, umode_t mode, struct xfs_inode **ipp);
> int xfs_readlink(struct xfs_inode *ip, char *link);
> -int xfs_inactive_symlink_rmt(struct xfs_inode *ip, struct xfs_trans **tpp);
> +int xfs_inactive_symlink(struct xfs_inode *ip, struct xfs_trans **tpp);
>
> #endif /* __KERNEL__ */
> #endif /* __XFS_SYMLINK_H */
> Index: b/fs/xfs/xfs_trace.h
> ===================================================================
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -594,6 +594,8 @@ DEFINE_INODE_EVENT(xfs_inode_set_eofbloc
> DEFINE_INODE_EVENT(xfs_inode_clear_eofblocks_tag);
> DEFINE_INODE_EVENT(xfs_inode_free_eofblocks_invalid);
>
> +DEFINE_INODE_EVENT(xfs_symlink_inactive);
> +
No need for the extra whitespace, just put it hard up against the
other DEFINE_INODE_EVENT()s. Might be better to put it directly
after the readlink trace definition.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree
2013-06-14 2:17 ` Dave Chinner
@ 2013-06-14 13:30 ` Mark Tinguely
0 siblings, 0 replies; 5+ messages in thread
From: Mark Tinguely @ 2013-06-14 13:30 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On 06/13/13 21:17, Dave Chinner wrote:
> On Thu, Jun 13, 2013 at 12:04:49PM -0500, Mark Tinguely wrote:
>> Adding an extended attribute to a symbolic link can force that
>> link to an remote extent. xfs_inactive() incorrectly assumes
>> that any symbolic link small enough to be in the inode core
>> is incore, resulting in the remote extent to not be removed.
>> xfs_ifree() will assert on presence of this leaked remote extent.
>>
>> Signed-off-by: Mark Tinguely<tinguely@sgi.com>
> .....
>> +/*
>> + * xfs_inactive_symlink - free a symlink
>> + */
>> +int
>> +xfs_inactive_symlink(
>> + struct xfs_inode *ip,
>> + struct xfs_trans **tp)
>> +{
>> + struct xfs_mount *mp = ip->i_mount;
>> + xfs_fsize_t pathlen;
>
> int will do here - it can't be more than MAXPATHLEN = 1024, and this
> gets rid of the casts in the error print.
>
>> +
>> + trace_xfs_readlink(ip);
>
> trace_xfs_inactive_symlink, as you mentioned ;)
sigh, and I reverted the inactive and symlink in the trace below. sigh
again.
>
>> +
>> + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
>> +
>> + if (XFS_FORCED_SHUTDOWN(mp))
>> + return XFS_ERROR(EIO);
>> +
>> + /*
>> + * Zero length symlinks _can_ exist.
>> + */
>> + pathlen = ip->i_d.di_size;
>> + if (!pathlen)
>> + return 0;
>> +
>> + if (pathlen< 0 || pathlen> MAXPATHLEN) {
>> + xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)",
>> + __func__, (unsigned long long) ip->i_ino,
> ^ whitespace
>> + (long long) pathlen);
>
> Can we change this to a hex-based inode number (much easier to read)
> and the pathlen cast can go away if you use an int. i.e.:
>
> xfs_alert(mp, "%s: inode (0x%llx) bad symlink length (%d)",
> __func__, (unsigned long long)ip->i_ino, pathlen);
>
>
Both of the items above were stole directly from xfs_readlink().
Thought they should be consistent(ly wrong :) ).
>> + ASSERT(0);
>> + return XFS_ERROR(EFSCORRUPTED);
>> + }
>> +
>> + if (ip->i_df.if_flags& XFS_IFINLINE) {
>> + if (ip->i_df.if_bytes> 0)
>> + xfs_idata_realloc(ip, -(ip->i_df.if_bytes),
>> + XFS_DATA_FORK);
>> + ASSERT(ip->i_df.if_bytes == 0);
>> + return 0;
>> + }
>> +
>> + /* remove the remote symlink */
>> + return(xfs_inactive_symlink_rmt(ip, tp));
>
> And no () around xfs_inactive_symlink_rmt().
>
>> +}
>> Index: b/fs/xfs/xfs_symlink.h
>> ===================================================================
>> --- a/fs/xfs/xfs_symlink.h
>> +++ b/fs/xfs/xfs_symlink.h
>> @@ -60,7 +60,7 @@ extern const struct xfs_buf_ops xfs_syml
>> int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
>> const char *target_path, umode_t mode, struct xfs_inode **ipp);
>> int xfs_readlink(struct xfs_inode *ip, char *link);
>> -int xfs_inactive_symlink_rmt(struct xfs_inode *ip, struct xfs_trans **tpp);
>> +int xfs_inactive_symlink(struct xfs_inode *ip, struct xfs_trans **tpp);
>>
>> #endif /* __KERNEL__ */
>> #endif /* __XFS_SYMLINK_H */
>> Index: b/fs/xfs/xfs_trace.h
>> ===================================================================
>> --- a/fs/xfs/xfs_trace.h
>> +++ b/fs/xfs/xfs_trace.h
>> @@ -594,6 +594,8 @@ DEFINE_INODE_EVENT(xfs_inode_set_eofbloc
>> DEFINE_INODE_EVENT(xfs_inode_clear_eofblocks_tag);
>> DEFINE_INODE_EVENT(xfs_inode_free_eofblocks_invalid);
>>
>> +DEFINE_INODE_EVENT(xfs_symlink_inactive);
>> +
>
> No need for the extra whitespace, just put it hard up against the
> other DEFINE_INODE_EVENT()s. Might be better to put it directly
> after the readlink trace definition.
>
> Cheers,
>
> Dave.
Thanks.
--Mark.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-06-14 13:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 17:04 [PATCH v3] xfs: fix the symbolic link assert in xfs_ifree Mark Tinguely
2013-06-13 17:50 ` Mark Tinguely
2013-06-13 17:53 ` Mark Tinguely
2013-06-14 2:17 ` Dave Chinner
2013-06-14 13:30 ` Mark Tinguely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox