Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150634364
D19848.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
28 KB
Referenced Files
None
Subscribers
None
D19848.diff
View Options
Index: head/sys/fs/ext2fs/ext2_alloc.c
===================================================================
--- head/sys/fs/ext2fs/ext2_alloc.c
+++ head/sys/fs/ext2fs/ext2_alloc.c
@@ -42,6 +42,7 @@
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/vnode.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
@@ -55,6 +56,23 @@
#include <fs/ext2fs/ext2fs.h>
#include <fs/ext2fs/ext2_extern.h>
+SDT_PROVIDER_DEFINE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , alloc, trace, "int", "char*");
+SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_reallocblks_realloc,
+ "ino_t", "e2fs_lbn_t", "e2fs_lbn_t");
+SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_bap, "uint32_t");
+SDT_PROBE_DEFINE1(ext2fs, , alloc, ext2_reallocblks_blkno, "e2fs_daddr_t");
+SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_b_bitmap_validate_error, "char*", "int");
+SDT_PROBE_DEFINE3(ext2fs, , alloc, ext2_nodealloccg_bmap_corrupted,
+ "int", "daddr_t", "char*");
+SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_blkfree_bad_block, "ino_t", "e4fs_daddr_t");
+SDT_PROBE_DEFINE2(ext2fs, , alloc, ext2_vfree_doublefree, "char*", "ino_t");
+
static daddr_t ext2_alloccg(struct inode *, int, daddr_t, int);
static daddr_t ext2_clusteralloc(struct inode *, int, daddr_t, int);
static u_long ext2_dirpref(struct inode *);
@@ -128,8 +146,7 @@
}
nospace:
EXT2_UNLOCK(ump);
- ext2_fserr(fs, cred->cr_uid, "filesystem full");
- uprintf("\n%s: write failed, filesystem is full\n", fs->e2fs_fsmnt);
+ SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate data block");
return (ENOSPC);
}
@@ -147,8 +164,10 @@
EXT2_LOCK(ip->i_ump);
blk = ext2_hashalloc(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize,
ext2_alloccg);
- if (0 == blk)
+ if (0 == blk) {
EXT2_UNLOCK(ip->i_ump);
+ SDT_PROBE2(ext2fs, , alloc, trace, 1, "cannot allocate meta block");
+ }
return (blk);
}
@@ -289,10 +308,8 @@
* block pointers in the inode and indirect blocks associated
* with the file.
*/
-#ifdef DEBUG
- printf("realloc: ino %ju, lbns %jd-%jd\n\told:",
- (uintmax_t)ip->i_number, (intmax_t)start_lbn, (intmax_t)end_lbn);
-#endif /* DEBUG */
+ SDT_PROBE3(ext2fs, , alloc, ext2_reallocblks_realloc,
+ ip->i_number, start_lbn, end_lbn);
blkno = newblk;
for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->e2fs_fpb) {
if (i == ssize) {
@@ -303,9 +320,7 @@
if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap))
panic("ext2_reallocblks: alloc mismatch");
#endif
-#ifdef DEBUG
- printf(" %d,", *bap);
-#endif /* DEBUG */
+ SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_bap, *bap);
*bap++ = blkno;
}
/*
@@ -341,20 +356,13 @@
/*
* Last, free the old blocks and assign the new blocks to the buffers.
*/
-#ifdef DEBUG
- printf("\n\tnew:");
-#endif /* DEBUG */
for (blkno = newblk, i = 0; i < len; i++, blkno += fs->e2fs_fpb) {
ext2_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno),
fs->e2fs_bsize);
buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
-#ifdef DEBUG
- printf(" %d,", blkno);
-#endif /* DEBUG */
+ SDT_PROBE1(ext2fs, , alloc, ext2_reallocblks_blkno, blkno);
}
-#ifdef DEBUG
- printf("\n");
-#endif /* DEBUG */
+
return (0);
fail:
@@ -481,8 +489,7 @@
noinodes:
EXT2_UNLOCK(ump);
- ext2_fserr(fs, cred->cr_uid, "out of inodes");
- uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt);
+ SDT_PROBE2(ext2fs, , alloc, trace, 1, "out of inodes");
return (ENOSPC);
}
@@ -959,21 +966,24 @@
/* Check block bitmap block number */
offset = e2fs_gd_get_b_bitmap(gd) - group_first_block;
if (offset >= max_bit || !isset(bp->b_data, offset)) {
- printf("ext2fs: bad block bitmap, group %d\n", cg);
+ SDT_PROBE2(ext2fs, , alloc, ext2_b_bitmap_validate_error,
+ "bad block bitmap, group", cg);
return (EINVAL);
}
/* Check inode bitmap block number */
offset = e2fs_gd_get_i_bitmap(gd) - group_first_block;
if (offset >= max_bit || !isset(bp->b_data, offset)) {
- printf("ext2fs: bad inode bitmap, group %d\n", cg);
+ SDT_PROBE2(ext2fs, , alloc, ext2_b_bitmap_validate_error,
+ "bad inode bitmap", cg);
return (EINVAL);
}
/* Check inode table */
offset = e2fs_gd_get_i_tables(gd) - group_first_block;
if (offset >= max_bit || offset + fs->e2fs_itpg >= max_bit) {
- printf("ext2fs: bad inode table, group %d\n", cg);
+ SDT_PROBE2(ext2fs, , alloc, ext2_b_bitmap_validate_error,
+ "bad inode table, group", cg);
return (EINVAL);
}
@@ -1350,9 +1360,8 @@
start = 0;
loc = memcchr(&ibp[start], 0xff, len);
if (loc == NULL) {
- printf("ext2fs: inode bitmap corrupted: "
- "cg = %d, ipref = %lld, fs = %s - run fsck\n",
- cg, (long long)ipref, fs->e2fs_fsmnt);
+ SDT_PROBE3(ext2fs, , alloc, ext2_nodealloccg_bmap_corrupted,
+ cg, ipref, fs->e2fs_fsmnt);
brelse(bp);
EXT2_LOCK(ump);
return (0);
@@ -1401,9 +1410,7 @@
ump = ip->i_ump;
cg = dtog(fs, bno);
if (bno >= fs->e2fs_bcount) {
- printf("bad block %lld, ino %ju\n", (long long)bno,
- (uintmax_t)ip->i_number);
- ext2_fserr(fs, ip->i_uid, "bad block");
+ SDT_PROBE2(ext2fs, , alloc, ext2_blkfree_bad_block, ip->i_number, bno);
return;
}
error = bread(ip->i_devvp,
@@ -1416,9 +1423,8 @@
bbp = (char *)bp->b_data;
bno = dtogd(fs, bno);
if (isclr(bbp, bno)) {
- printf("block = %lld, fs = %s\n",
+ panic("ext2_blkfree: freeing free block %lld, fs=%s",
(long long)bno, fs->e2fs_fsmnt);
- panic("ext2_blkfree: freeing free block");
}
clrbit(bbp, bno);
EXT2_LOCK(ump);
@@ -1464,8 +1470,8 @@
ibp = (char *)bp->b_data;
ino = (ino - 1) % fs->e2fs->e2fs_ipg;
if (isclr(ibp, ino)) {
- printf("ino = %ju, fs = %s\n",
- ino, fs->e2fs_fsmnt);
+ SDT_PROBE2(ext2fs, , alloc, ext2_vfree_doublefree,
+ fs->e2fs_fsmnt, ino);
if (fs->e2fs_ronly == 0)
panic("ext2_vfree: freeing free inode");
}
@@ -1513,26 +1519,12 @@
start = 0;
loc = memcchr(&bbp[start], 0xff, len);
if (loc == NULL) {
- printf("start = %d, len = %d, fs = %s\n",
+ panic("ext2_mapsearch: map corrupted: start=%d, len=%d, fs=%s",
start, len, fs->e2fs_fsmnt);
- panic("ext2_mapsearch: map corrupted");
/* NOTREACHED */
}
}
return ((loc - bbp) * NBBY + ffs(~*loc) - 1);
-}
-
-/*
- * Fserr prints the name of a filesystem with an error diagnostic.
- *
- * The form of the error message is:
- * fs: error message
- */
-void
-ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp)
-{
-
- log(LOG_ERR, "uid %u on %s: %s\n", uid, fs->e2fs_fsmnt, cp);
}
int
Index: head/sys/fs/ext2fs/ext2_csum.c
===================================================================
--- head/sys/fs/ext2fs/ext2_csum.c
+++ head/sys/fs/ext2fs/ext2_csum.c
@@ -31,6 +31,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/types.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -50,6 +51,14 @@
#include <fs/ext2fs/ext2_extattr.h>
#include <fs/ext2fs/ext2_extern.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , trace, csum, "int", "char*");
+
#define EXT2_BG_INODE_BITMAP_CSUM_HI_END \
(offsetof(struct ext2_gd, ext4bgd_i_bmap_csum_hi) + \
sizeof(uint16_t))
@@ -134,8 +143,7 @@
if (EXT2_HAS_RO_COMPAT_FEATURE(ip->i_e2fs, EXT2F_ROCOMPAT_METADATA_CKSUM) &&
(header->h_checksum != ext2_extattr_blk_csum(ip, ip->i_facl, header))) {
- printf("WARNING: bad extattr csum detected, ip=%lu - run fsck\n",
- (unsigned long)ip->i_number);
+ SDT_PROBE2(ext2fs, , trace, csum, 1, "bad extattr csum detected");
return (EIO);
}
@@ -351,8 +359,7 @@
error = ext2_dx_csum_verify(ip, ep);
if (error)
- printf("WARNING: bad directory csum detected, ip=%lu"
- " - run fsck\n", (unsigned long)ip->i_number);
+ SDT_PROBE2(ext2fs, , trace, csum, 1, "bad directory csum detected");
return (error);
}
@@ -445,8 +452,7 @@
calculated = ext2_extent_blk_csum(ip, ehp);
if (provided != calculated) {
- printf("WARNING: bad extent csum detected, ip=%lu - run fsck\n",
- (unsigned long)ip->i_number);
+ SDT_PROBE2(ext2fs, , trace, csum, 1, "bad extent csum detected");
return (EIO);
}
@@ -491,8 +497,7 @@
calculated &= 0xFFFF;
if (provided != calculated) {
- printf("WARNING: bad inode bitmap csum detected, "
- "cg=%d - run fsck\n", cg);
+ SDT_PROBE2(ext2fs, , trace, csum, 1, "bad inode bitmap csum detected");
return (EIO);
}
@@ -532,8 +537,7 @@
calculated &= 0xFFFF;
if (provided != calculated) {
- printf("WARNING: bad block bitmap csum detected, "
- "cg=%d - run fsck\n", cg);
+ SDT_PROBE2(ext2fs, , trace, csum, 1, "bad block bitmap csum detected");
return (EIO);
}
@@ -629,7 +633,7 @@
if (!memcmp(ei, &ei_zero, sizeof(struct ext2fs_dinode)))
return (0);
- printf("WARNING: Bad inode %ju csum - run fsck\n", ip->i_number);
+ SDT_PROBE2(ext2fs, , trace, csum, 1, "bad inode csum");
return (EIO);
}
Index: head/sys/fs/ext2fs/ext2_extattr.c
===================================================================
--- head/sys/fs/ext2fs/ext2_extattr.c
+++ head/sys/fs/ext2fs/ext2_extattr.c
@@ -39,6 +39,7 @@
#include <sys/endian.h>
#include <sys/conf.h>
#include <sys/extattr.h>
+#include <sys/sdt.h>
#include <fs/ext2fs/fs.h>
#include <fs/ext2fs/ext2fs.h>
@@ -48,6 +49,14 @@
#include <fs/ext2fs/ext2_extattr.h>
#include <fs/ext2fs/ext2_extern.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , trace, extattr, "int", "char*");
+
static int
ext2_extattr_attrnamespace_to_bsd(int attrnamespace)
{
@@ -89,9 +98,8 @@
* XXX: Not all linux namespaces are mapped to bsd for now,
* return NULL, which will be converted to ENOTSUP on upper layer.
*/
-#ifdef EXT2FS_DEBUG
- printf("can not convert ext2fs name to bsd: namespace=%d\n", attrnamespace);
-#endif
+ SDT_PROBE2(ext2fs, , trace, extattr, 1,
+ "can not convert ext2fs name to bsd namespace");
return (NULL);
}
Index: head/sys/fs/ext2fs/ext2_extents.h
===================================================================
--- head/sys/fs/ext2fs/ext2_extents.h
+++ head/sys/fs/ext2fs/ext2_extents.h
@@ -129,7 +129,7 @@
int ext4_ext_get_blocks(struct inode *ip, int64_t iblock,
unsigned long max_blocks, struct ucred *cred, struct buf **bpp,
int *allocate, daddr_t *);
-#ifdef EXT2FS_DEBUG
+#ifdef EXT2FS_PRINT_EXTENTS
void ext4_ext_print_extent_tree_status(struct inode *ip);
#endif
Index: head/sys/fs/ext2fs/ext2_extern.h
===================================================================
--- head/sys/fs/ext2fs/ext2_extern.h
+++ head/sys/fs/ext2fs/ext2_extern.h
@@ -66,7 +66,6 @@
int ext4_bmapext(struct vnode *, int32_t, int64_t *, int *, int *);
void ext2_clusteracct(struct m_ext2fs *, char *, int, e4fs_daddr_t, int);
void ext2_dirbad(struct inode *ip, doff_t offset, char *how);
-void ext2_fserr(struct m_ext2fs *, uid_t, char *);
int ext2_ei2i(struct ext2fs_dinode *, struct inode *);
int ext2_getlbns(struct vnode *, daddr_t, struct indir *, int *);
int ext2_i2ei(struct inode *, struct ext2fs_dinode *);
@@ -80,7 +79,7 @@
int ext2_vinit(struct mount *, struct vop_vector *, struct vnode **vpp);
int ext2_lookup(struct vop_cachedlookup_args *);
int ext2_readdir(struct vop_readdir_args *);
-#ifdef EXT2FS_DEBUG
+#ifdef EXT2FS_PRINT_EXTENTS
void ext2_print_inode(struct inode *);
#endif
int ext2_direnter(struct inode *,
Index: head/sys/fs/ext2fs/ext2_hash.c
===================================================================
--- head/sys/fs/ext2fs/ext2_hash.c
+++ head/sys/fs/ext2fs/ext2_hash.c
@@ -57,6 +57,7 @@
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/vnode.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/mount.h>
@@ -67,6 +68,14 @@
#include <fs/ext2fs/ext2_mount.h>
#include <fs/ext2fs/ext2_extern.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , trace, hash, "int", "char*");
+
/* F, G, and H are MD4 functions */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
@@ -300,6 +309,7 @@
minor = hash[2];
break;
default:
+ SDT_PROBE2(ext2fs, , trace, hash, 1, "unexpected hash version");
goto error;
}
Index: head/sys/fs/ext2fs/ext2_htree.c
===================================================================
--- head/sys/fs/ext2fs/ext2_htree.c
+++ head/sys/fs/ext2fs/ext2_htree.c
@@ -40,6 +40,7 @@
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <sys/dirent.h>
+#include <sys/sdt.h>
#include <sys/sysctl.h>
#include <ufs/ufs/dir.h>
@@ -54,6 +55,14 @@
#include <fs/ext2fs/ext2_dir.h>
#include <fs/ext2fs/htree.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , trace, htree, "int", "char*");
+
static void ext2_append_entry(char *block, uint32_t blksize,
struct ext2fs_direct_2 *last_entry,
struct ext2fs_direct_2 *new_entry, int csum_size);
@@ -816,7 +825,8 @@
if (ext2_htree_get_count(root_entires) ==
ext2_htree_get_limit(root_entires)) {
- /* Directory index is full */
+ SDT_PROBE2(ext2fs, , trace, htree, 1,
+ "directory index is full");
error = EIO;
goto finish;
}
Index: head/sys/fs/ext2fs/ext2_inode.c
===================================================================
--- head/sys/fs/ext2fs/ext2_inode.c
+++ head/sys/fs/ext2fs/ext2_inode.c
@@ -46,6 +46,7 @@
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <sys/rwlock.h>
+#include <sys/sdt.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
Index: head/sys/fs/ext2fs/ext2_inode_cnv.c
===================================================================
--- head/sys/fs/ext2fs/ext2_inode_cnv.c
+++ head/sys/fs/ext2fs/ext2_inode_cnv.c
@@ -31,6 +31,7 @@
#include <sys/systm.h>
#include <sys/endian.h>
#include <sys/lock.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/vnode.h>
@@ -40,10 +41,18 @@
#include <fs/ext2fs/ext2_dinode.h>
#include <fs/ext2fs/ext2_extern.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , trace, inode_cnv, "int", "char*");
+
#define XTIME_TO_NSEC(x) ((x & EXT3_NSEC_MASK) >> 2)
#define NSEC_TO_XTIME(t) (le32toh(t << 2) & EXT3_NSEC_MASK)
-#ifdef EXT2FS_DEBUG
+#ifdef EXT2FS_PRINT_EXTENTS
void
ext2_print_inode(struct inode *in)
{
@@ -83,7 +92,7 @@
printf("\n");
}
}
-#endif /* EXT2FS_DEBUG */
+#endif /* EXT2FS_PRINT_EXTENTS */
/*
* raw ext2 inode to inode
@@ -96,12 +105,12 @@
if ((ip->i_number < EXT2_FIRST_INO(fs) && ip->i_number != EXT2_ROOTINO) ||
(ip->i_number < EXT2_ROOTINO) ||
(ip->i_number > fs->e2fs->e2fs_icount)) {
- printf("ext2fs: bad inode number %ju\n", ip->i_number);
+ SDT_PROBE2(ext2fs, , trace, inode_cnv, 1, "bad inode number");
return (EINVAL);
}
if (ip->i_number == EXT2_ROOTINO && ei->e2di_nlink == 0) {
- printf("ext2fs: root inode unallocated\n");
+ SDT_PROBE2(ext2fs, , trace, inode_cnv, 1, "root inode unallocated");
return (EINVAL);
}
ip->i_nlink = ei->e2di_nlink;
@@ -110,8 +119,8 @@
if (EXT2_INODE_SIZE(fs) > E2FS_REV0_INODE_SIZE) {
if (E2FS_REV0_INODE_SIZE + ei->e2di_extra_isize >
EXT2_INODE_SIZE(fs) || (ei->e2di_extra_isize & 3)) {
- printf("ext2fs: bad extra inode size %u, inode size=%u\n",
- ei->e2di_extra_isize, EXT2_INODE_SIZE(fs));
+ SDT_PROBE2(ext2fs, , trace, inode_cnv, 1,
+ "bad extra inode size");
return (EINVAL);
}
}
@@ -199,7 +208,7 @@
ei->e2di_flags |= (ip->i_flag & IN_E4EXTENTS) ? EXT4_EXTENTS : 0;
if (ip->i_blocks > ~0U &&
!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) {
- ext2_fserr(fs, ip->i_uid, "i_blocks value is out of range");
+ SDT_PROBE2(ext2fs, , trace, inode_cnv, 1, "i_blocks value is out of range");
return (EIO);
}
if (ip->i_blocks <= 0xffffffffffffULL) {
Index: head/sys/fs/ext2fs/ext2_lookup.c
===================================================================
--- head/sys/fs/ext2fs/ext2_lookup.c
+++ head/sys/fs/ext2fs/ext2_lookup.c
@@ -53,6 +53,7 @@
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <sys/dirent.h>
+#include <sys/sdt.h>
#include <sys/sysctl.h>
#include <ufs/ufs/dir.h>
@@ -66,6 +67,18 @@
#include <fs/ext2fs/ext2_extern.h>
#include <fs/ext2fs/fs.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , lookup, trace, "int", "char*");
+SDT_PROBE_DEFINE4(ext2fs, , trace, ext2_dirbad_error,
+ "char*", "ino_t", "doff_t", "char*");
+SDT_PROBE_DEFINE5(ext2fs, , trace, ext2_dirbadentry_error,
+ "char*", "int", "uint32_t", "uint16_t", "uint8_t");
+
#ifdef INVARIANTS
static int dirchk = 1;
#else
@@ -810,10 +823,8 @@
mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number,
(long)offset, how);
else
- (void)printf("%s: bad dir ino %ju at offset %ld: %s\n",
- mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number,
- (long)offset, how);
-
+ SDT_PROBE4(ext2fs, , trace, ext2_dirbad_error,
+ mp->mnt_stat.f_mntonname, ip->i_number, offset, how);
}
/*
@@ -849,10 +860,9 @@
*/
if (error_msg != NULL) {
- printf("bad directory entry: %s\n", error_msg);
- printf("offset=%d, inode=%lu, rec_len=%u, name_len=%u\n",
- entryoffsetinblock, (unsigned long)de->e2d_ino,
- de->e2d_reclen, de->e2d_namlen);
+ SDT_PROBE5(ext2fs, , trace, ext2_dirbadentry_error,
+ error_msg, entryoffsetinblock,
+ de->e2d_ino, de->e2d_reclen, de->e2d_namlen);
}
return error_msg == NULL ? 0 : 1;
}
@@ -1276,7 +1286,8 @@
out:
if (error == ENOTDIR)
- printf("checkpath: .. not a directory\n");
+ SDT_PROBE2(ext2fs, , lookup, trace, 1,
+ "checkpath: .. not a directory");
if (vp != NULL)
vput(vp);
return (error);
Index: head/sys/fs/ext2fs/ext2_subr.c
===================================================================
--- head/sys/fs/ext2fs/ext2_subr.c
+++ head/sys/fs/ext2fs/ext2_subr.c
@@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/buf.h>
Index: head/sys/fs/ext2fs/ext2_vfsops.c
===================================================================
--- head/sys/fs/ext2fs/ext2_vfsops.c
+++ head/sys/fs/ext2fs/ext2_vfsops.c
@@ -52,6 +52,7 @@
#include <sys/endian.h>
#include <sys/fcntl.h>
#include <sys/malloc.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/mutex.h>
@@ -67,7 +68,17 @@
#include <fs/ext2fs/ext2_extern.h>
#include <fs/ext2fs/ext2_extents.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , vfsops, trace, "int", "char*");
+SDT_PROBE_DEFINE2(ext2fs, , vfsops, ext2_cg_validate_error, "char*", "int");
+SDT_PROBE_DEFINE1(ext2fs, , vfsops, ext2_compute_sb_data_error, "char*");
+
static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td);
static int ext2_mountfs(struct vnode *, struct mount *);
static int ext2_reload(struct mount *mp, struct thread *td);
@@ -381,48 +392,54 @@
b_bitmap = e2fs_gd_get_b_bitmap(gd);
if (b_bitmap == 0) {
- printf("ext2fs: cg %u: block bitmap is zero\n", i);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "block bitmap is zero", i);
return (EINVAL);
}
if (b_bitmap <= last_cg_block) {
- printf("ext2fs: cg %u: block bitmap overlaps gds\n", i);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "block bitmap overlaps gds", i);
return (EINVAL);
}
if (b_bitmap < first_block || b_bitmap > last_block) {
- printf("ext2fs: cg %u: block bitmap not in group, blk=%ju\n",
- i, b_bitmap);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "block bitmap not in group", i);
return (EINVAL);
}
i_bitmap = e2fs_gd_get_i_bitmap(gd);
if (i_bitmap == 0) {
- printf("ext2fs: cg %u: inode bitmap is zero\n", i);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "inode bitmap is zero", i);
return (EINVAL);
}
if (i_bitmap <= last_cg_block) {
- printf("ext2fs: cg %u: inode bitmap overlaps gds\n", i);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "inode bitmap overlaps gds", i);
return (EINVAL);
}
if (i_bitmap < first_block || i_bitmap > last_block) {
- printf("ext2fs: cg %u: inode bitmap not in group blk=%ju\n",
- i, i_bitmap);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "inode bitmap not in group blk", i);
return (EINVAL);
}
i_tables = e2fs_gd_get_i_tables(gd);
if (i_tables == 0) {
- printf("ext2fs: cg %u: inode table is zero\n", i);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "inode table is zero", i);
return (EINVAL);
}
if (i_tables <= last_cg_block) {
- printf("ext2fs: cg %u: inode talbes overlaps gds\n", i);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "inode talbes overlaps gds", i);
return (EINVAL);
}
if (i_tables < first_block ||
i_tables + fs->e2fs_itpg - 1 > last_block) {
- printf("ext2fs: cg %u: inode tables not in group blk=%ju\n",
- i, i_tables);
+ SDT_PROBE2(ext2fs, , vfsops, ext2_cg_validate_error,
+ "inode tables not in group blk", i);
return (EINVAL);
}
@@ -450,7 +467,8 @@
/* Check checksum features */
if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) &&
EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_METADATA_CKSUM)) {
- printf("ext2fs: incorrect checksum features combination\n");
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "incorrect checksum features combination");
return (EINVAL);
}
@@ -467,7 +485,8 @@
/* Check for block size = 1K|2K|4K */
if (es->e2fs_log_bsize > 2) {
- printf("ext2fs: bad block size: %d\n", es->e2fs_log_bsize);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "bad block size");
return (EINVAL);
}
@@ -479,15 +498,15 @@
/* Check for fragment size */
if (es->e2fs_log_fsize >
(EXT2_MAX_FRAG_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) {
- printf("ext2fs: invalid log cluster size: %u\n",
- es->e2fs_log_fsize);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "invalid log cluster size");
return (EINVAL);
}
fs->e2fs_fsize = EXT2_MIN_FRAG_SIZE << es->e2fs_log_fsize;
if (fs->e2fs_fsize != fs->e2fs_bsize) {
- printf("ext2fs: fragment size (%u) != block size %u\n",
- fs->e2fs_fsize, fs->e2fs_bsize);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "fragment size != block size");
return (EINVAL);
}
@@ -495,8 +514,8 @@
/* Check reserved gdt blocks for future filesystem expansion */
if (es->e2fs_reserved_ngdb > (fs->e2fs_bsize / 4)) {
- printf("ext2fs: number of reserved GDT blocks too large: %u\n",
- es->e2fs_reserved_ngdb);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "number of reserved GDT blocks too large");
return (EINVAL);
}
@@ -509,8 +528,8 @@
* Check first ino.
*/
if (es->e2fs_first_ino < EXT2_FIRSTINO) {
- printf("ext2fs: invalid first ino: %u\n",
- es->e2fs_first_ino);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "invalid first ino");
return (EINVAL);
}
@@ -520,8 +539,8 @@
if (EXT2_INODE_SIZE(fs) < E2FS_REV0_INODE_SIZE ||
EXT2_INODE_SIZE(fs) > fs->e2fs_bsize ||
(fs->e2fs_isize & (fs->e2fs_isize - 1)) != 0) {
- printf("ext2fs: invalid inode size %u\n",
- fs->e2fs_isize);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "invalid inode size");
return (EINVAL);
}
}
@@ -529,33 +548,36 @@
/* Check group descriptors */
if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT) &&
es->e3fs_desc_size != E2FS_64BIT_GD_SIZE) {
- printf("ext2fs: unsupported 64bit descriptor size %u\n",
- es->e3fs_desc_size);
- return (EINVAL);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "unsupported 64bit descriptor size");
+ return (EINVAL);
}
fs->e2fs_bpg = es->e2fs_bpg;
fs->e2fs_fpg = es->e2fs_fpg;
if (fs->e2fs_bpg == 0 || fs->e2fs_fpg == 0) {
- printf("ext2fs: zero blocks/fragments per group\n");
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "zero blocks/fragments per group");
return (EINVAL);
}
if (fs->e2fs_bpg != fs->e2fs_bsize * 8) {
- printf("ext2fs: non-standard group size unsupported %d\n",
- fs->e2fs_bpg);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "non-standard group size unsupported");
return (EINVAL);
}
fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs);
if (fs->e2fs_ipb == 0 ||
fs->e2fs_ipb > fs->e2fs_bsize / E2FS_REV0_INODE_SIZE) {
- printf("ext2fs: bad inodes per block size\n");
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "bad inodes per block size");
return (EINVAL);
}
fs->e2fs_ipg = es->e2fs_ipg;
if (fs->e2fs_ipg < fs->e2fs_ipb || fs->e2fs_ipg > fs->e2fs_bsize * 8) {
- printf("ext2fs: invalid inodes per group: %u\n", fs->e2fs_ipb);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "invalid inodes per group");
return (EINVAL);
}
@@ -571,25 +593,29 @@
}
if (fs->e2fs_rbcount > fs->e2fs_bcount ||
fs->e2fs_fbcount > fs->e2fs_bcount) {
- printf("ext2fs: invalid block count\n");
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "invalid block count");
return (EINVAL);
}
if (es->e2fs_first_dblock >= fs->e2fs_bcount) {
- printf("ext2fs: first data block out of range\n");
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "first data block out of range");
return (EINVAL);
}
fs->e2fs_gcount = howmany(fs->e2fs_bcount - es->e2fs_first_dblock,
EXT2_BLOCKS_PER_GROUP(fs));
if (fs->e2fs_gcount > ((uint64_t)1 << 32) - EXT2_DESCS_PER_BLOCK(fs)) {
- printf("ext2fs: groups count too large: %u\n", fs->e2fs_gcount);
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "groups count too large");
return (EINVAL);
}
/* Check for extra isize in big inodes. */
if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_EXTRA_ISIZE) &&
EXT2_INODE_SIZE(fs) < sizeof(struct ext2fs_dinode)) {
- printf("ext2fs: no space for extra inode timestamps\n");
+ SDT_PROBE1(ext2fs, , vfsops, ext2_compute_sb_data_error,
+ "no space for extra inode timestamps");
return (EINVAL);
}
@@ -1095,8 +1121,7 @@
td = curthread;
fs = ump->um_e2fs;
if (fs->e2fs_fmod != 0 && fs->e2fs_ronly != 0) { /* XXX */
- printf("fs = %s\n", fs->e2fs_fsmnt);
- panic("ext2_sync: rofs mod");
+ panic("ext2_sync: rofs mod fs=%s", fs->e2fs_fsmnt);
}
/*
@@ -1242,7 +1267,7 @@
for (i = used_blocks; i < EXT2_NDIR_BLOCKS; i++)
ip->i_db[i] = 0;
}
-#ifdef EXT2FS_DEBUG
+#ifdef EXT2FS_PRINT_EXTENTS
ext2_print_inode(ip);
ext4_ext_print_extent_tree_status(ip);
#endif
Index: head/sys/fs/ext2fs/ext2_vnops.c
===================================================================
--- head/sys/fs/ext2fs/ext2_vnops.c
+++ head/sys/fs/ext2fs/ext2_vnops.c
@@ -51,6 +51,7 @@
#include <sys/kernel.h>
#include <sys/fcntl.h>
#include <sys/filio.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/bio.h>
#include <sys/buf.h>
@@ -92,6 +93,14 @@
#include <fs/ext2fs/ext2_extattr.h>
#include <fs/ext2fs/ext2_extents.h>
+SDT_PROVIDER_DECLARE(ext2fs);
+/*
+ * ext2fs trace probe:
+ * arg0: verbosity. Higher numbers give more verbose messages
+ * arg1: Textual message
+ */
+SDT_PROBE_DEFINE2(ext2fs, , vnops, trace, "int", "char*");
+
static int ext2_makeinode(int mode, struct vnode *, struct vnode **, struct componentname *);
static void ext2_itimes_locked(struct vnode *);
@@ -813,7 +822,8 @@
* not call us in that case. Temporarily just warn if they do.
*/
if (fvp == tvp) {
- printf("ext2_rename: fvp == tvp (can't happen)\n");
+ SDT_PROBE2(ext2fs, , vnops, trace, 1,
+ "rename: fvp == tvp (can't happen)");
error = 0;
goto abortit;
}
Index: head/sys/fs/ext2fs/fs.h
===================================================================
--- head/sys/fs/ext2fs/fs.h
+++ head/sys/fs/ext2fs/fs.h
@@ -164,6 +164,6 @@
/*
* Use if additional debug logging is required.
*/
-/* #define EXT2FS_DEBUG */
+/* #define EXT2FS_PRINT_EXTENTS */
#endif /* !_FS_EXT2FS_FS_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 11:43 PM (9 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30785841
Default Alt Text
D19848.diff (28 KB)
Attached To
Mode
D19848: ext2fs: Dtrace support.
Attached
Detach File
Event Timeline
Log In to Comment