===================================================================
--- linux-stage.orig/fs/ext4/namei.c
+++ linux-stage/fs/ext4/namei.c
-@@ -1709,9 +1709,8 @@ static void ext4_inc_count(handle_t *han
+@@ -1609,7 +1709,7 @@ static void ext4_inc_count(handle_t *han
+ * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2,
+ * since this indicates that nlinks count was previously 1.
*/
- static void ext4_dec_count(handle_t *handle, struct inode *inode)
+-static void ext4_inc_count(handle_t *handle, struct inode *inode)
++void ext4_inc_count(handle_t *handle, struct inode *inode)
+ {
+ inc_nlink(inode);
+ if (is_dx(inode) && inode->i_nlink > 1) {
+@@ -1709,17 +1709,18 @@ static void ext4_inc_count(handle_t *han
+ }
+ }
+ }
++EXPORT_SYMBOL(ext4_inc_count);
+
+ /*
+ * If a directory had nlink == 1, then we should let it be 1. This indicates
+ * directory has >EXT4_LINK_MAX subdirs.
+ */
+-static void ext4_dec_count(handle_t *handle, struct inode *inode)
++void ext4_dec_count(handle_t *handle, struct inode *inode)
{
- drop_nlink(inode);
- if (S_ISDIR(inode->i_mode) && inode->i_nlink == 0)
+ if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2)
+ drop_nlink(inode);
}
++EXPORT_SYMBOL(ext4_dec_count);
+
+
+ static int ext4_add_nondir(handle_t *handle,
#include <linux/fs.h>
#include <linux/quota.h>
],[
- struct quotactl_ops qops = {};
- struct fs_disk_quota fdq;
- qops.set_dqblk(NULL, 0, 0, &fdq);
+ ((struct quotactl_ops *)0)->set_dqblk(NULL, 0, 0, (struct fs_disk_quota*)0);
],[
AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota])
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
+ AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid & fs_disk_quota])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ #include <linux/quota.h>
+ ],[
+ ((struct quotactl_ops *)0)->set_dqblk((struct super_block*)0, *((struct kqid*)0), (struct fs_disk_quota*)0);
+ ],[
+ AC_DEFINE(HAVE_DQUOT_FS_DISK_QUOTA, 1, [quotactl_ops.set_dqblk takes struct fs_disk_quota])
+ AC_DEFINE(HAVE_DQUOT_KQID, 1, [quotactl_ops.set_dqblk takes struct kqid])
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_CHECKING([if quotactl_ops.set_dqblk takes struct kqid&fs_disk_quota])
+ ])
])
EXTRA_KCFLAGS="$tmp_flags"
])
])
#
+# truncate callback removed since 2.6.39
+#
+AC_DEFUN([LC_IOP_TRUNCATE],
+[AC_MSG_CHECKING([inode_operations has .truncate member function])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ ((struct inode_operations *)0)->truncate(NULL);
+],[
+ AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
+ [inode_operations has .truncate member function])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
# 2.6.39 remove unplug_fn from request_queue.
#
AC_DEFUN([LC_REQUEST_QUEUE_UNPLUG_FN],
# 2.6.39
LC_REQUEST_QUEUE_UNPLUG_FN
LC_HAVE_FSTYPE_MOUNT
+ LC_IOP_TRUNCATE
# 3.0
LC_DIRTY_INODE_WITH_FLAG
NULL);
CDEBUG(D_INODE, "%s: add %s:%lu to remote parent %lu.\n", osd_name(osd),
name, obj->oo_inode->i_ino, parent->d_inode->i_ino);
- LASSERTF(parent->d_inode->i_nlink > 1, "%s: %lu nlink %d",
- osd_name(osd), parent->d_inode->i_ino,
- parent->d_inode->i_nlink);
- parent->d_inode->i_nlink++;
+ ldiskfs_inc_count(oh->ot_handle, parent->d_inode);
mark_inode_dirty(parent->d_inode);
mutex_unlock(&parent->d_inode->i_mutex);
RETURN(rc);
dentry = osd_child_dentry_by_inode(env, parent->d_inode,
name, strlen(name));
mutex_lock(&parent->d_inode->i_mutex);
- bh = osd_ldiskfs_find_entry(parent->d_inode, dentry, &de, NULL);
+ bh = osd_ldiskfs_find_entry(parent->d_inode, &dentry->d_name, &de,
+ NULL, NULL);
if (bh == NULL) {
mutex_unlock(&parent->d_inode->i_mutex);
RETURN(-ENOENT);
CDEBUG(D_INODE, "%s: el %s:%lu to remote parent %lu.\n", osd_name(osd),
name, obj->oo_inode->i_ino, parent->d_inode->i_ino);
rc = ldiskfs_delete_entry(oh->ot_handle, parent->d_inode, de, bh);
- LASSERTF(parent->d_inode->i_nlink > 1, "%s: %lu nlink %d",
- osd_name(osd), parent->d_inode->i_ino,
- parent->d_inode->i_nlink);
- parent->d_inode->i_nlink--;
+ ldiskfs_dec_count(oh->ot_handle, parent->d_inode);
mark_inode_dirty(parent->d_inode);
mutex_unlock(&parent->d_inode->i_mutex);
brelse(bh);
dentry = osd_child_dentry_by_inode(oti->oti_env, parent->d_inode,
name, strlen(name));
mutex_lock(&parent->d_inode->i_mutex);
- bh = osd_ldiskfs_find_entry(parent->d_inode, dentry, &de, NULL);
+ bh = osd_ldiskfs_find_entry(parent->d_inode, &dentry->d_name, &de,
+ NULL, NULL);
if (bh == NULL) {
rc = -ENOENT;
} else {
ll_vfs_dq_init(parent);
mutex_lock(&parent->i_mutex);
- bh = osd_ldiskfs_find_entry(parent, child, &de, NULL);
+ bh = osd_ldiskfs_find_entry(parent, &child->d_name, &de, NULL, NULL);
if (bh == NULL)
GOTO(out, rc = -ENOENT);
ll_vfs_dq_init(dir);
mutex_lock(&dir->i_mutex);
rc = -ENOENT;
- bh = osd_ldiskfs_find_entry(dir, child, &de, NULL);
+ bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL);
if (bh) {
rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh);
brelse(bh);
dir = d_seq->d_inode;
mutex_lock(&dir->i_mutex);
- bh = osd_ldiskfs_find_entry(dir, child, &de, NULL);
+ bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL);
mutex_unlock(&dir->i_mutex);
if (bh == NULL)
tgt_child->d_inode = inode;
/* The non-initialized src_child may be destroyed. */
- jh = ldiskfs_journal_start_sb(osd_sb(osd),
+ jh = osd_journal_start_sb(osd_sb(osd), LDISKFS_HT_MISC,
osd_dto_credits_noquota[DTO_INDEX_DELETE] +
osd_dto_credits_noquota[DTO_INDEX_INSERT] +
osd_dto_credits_noquota[DTO_OBJECT_DELETE]);
mutex_lock(&src_parent->i_mutex);
mutex_lock(&dir->i_mutex);
- bh = osd_ldiskfs_find_entry(dir, tgt_child, &de, NULL);
+ bh = osd_ldiskfs_find_entry(dir, &tgt_child->d_name, &de, NULL, NULL);
if (bh != NULL) {
/* XXX: If some other object occupied the same slot. And If such
* inode is zero-sized and with SUID+SGID, then means it is
/* If the src object has never been modified, then remove it. */
if (inode->i_size == 0 && inode->i_mode & S_ISUID &&
inode->i_mode & S_ISGID) {
- bh = osd_ldiskfs_find_entry(src_parent, src_child, &de,
- NULL);
+ bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name,
+ &de, NULL, NULL);
if (unlikely(bh == NULL)) {
mutex_unlock(&src_parent->i_mutex);
ldiskfs_journal_stop(jh);
RETURN(rc);
}
- bh = osd_ldiskfs_find_entry(src_parent, src_child, &de, NULL);
+ bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name, &de,
+ NULL, NULL);
if (unlikely(bh == NULL))
GOTO(unlock, rc = -ENOENT);
LASSERT(current->journal_info == NULL);
- jh = ldiskfs_journal_start_sb(osd_sb(osd),
+ jh = osd_journal_start_sb(osd_sb(osd), LDISKFS_HT_MISC,
osd_dto_credits_noquota[DTO_XATTR_SET]);
if (IS_ERR(jh)) {
CWARN("%s: cannot start journal for "
* XXX temporary stuff. Some abstraction layer should
* be used.
*/
- jh = ldiskfs_journal_start_sb(osd_sb(dev), oh->ot_credits);
+ jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC, oh->ot_credits);
osd_th_started(oh);
if (!IS_ERR(jh)) {
oh->ot_handle = jh;
RETURN(-EPERM);
if (S_ISDIR(inode->i_mode)) {
- LASSERT(osd_inode_unlinked(inode) || inode->i_nlink == 1);
+ LASSERT(osd_inode_unlinked(inode) || inode->i_nlink == 1 ||
+ inode->i_nlink == 2);
/* it will check/delete the inode from remote parent,
* how to optimize it? unlink performance impaction XXX */
result = osd_delete_from_remote_parent(env, osd, obj, oh);
static int osd_object_ref_add(const struct lu_env *env,
struct dt_object *dt, struct thandle *th)
{
- struct osd_object *obj = osd_dt_obj(dt);
- struct inode *inode = obj->oo_inode;
- bool need_dirty = false;
- int rc = 0;
+ struct osd_object *obj = osd_dt_obj(dt);
+ struct inode *inode = obj->oo_inode;
+ struct osd_thandle *oh;
+ int rc = 0;
LINVRNT(osd_invariant(obj));
LASSERT(dt_object_exists(dt) && !dt_object_remote(dt));
LASSERT(osd_write_locked(env, obj));
LASSERT(th != NULL);
+ oh = container_of0(th, struct osd_thandle, ot_super);
+ LASSERT(oh->ot_handle != NULL);
+
osd_trans_exec_op(env, th, OSD_OT_REF_ADD);
- /* This based on ldiskfs_inc_count(), which is not exported.
- *
+ /*
* The DIR_NLINK feature allows directories to exceed LDISKFS_LINK_MAX
* (65000) subdirectories by storing "1" in i_nlink if the link count
* would otherwise overflow. Directory tranversal tools understand
* in case they are being linked into the PENDING directory
*/
spin_lock(&obj->oo_guard);
- if (unlikely(!S_ISDIR(inode->i_mode) &&
- inode->i_nlink >= LDISKFS_LINK_MAX)) {
- /* MDD should have checked this, but good to be safe */
- rc = -EMLINK;
- } else if (unlikely(inode->i_nlink == 0 ||
- (S_ISDIR(inode->i_mode) &&
- inode->i_nlink >= LDISKFS_LINK_MAX))) {
- /* inc_nlink from 0 may cause WARN_ON */
- set_nlink(inode, 1);
- need_dirty = true;
- } else if (!S_ISDIR(inode->i_mode) ||
- (S_ISDIR(inode->i_mode) && inode->i_nlink >= 2)) {
- inc_nlink(inode);
- need_dirty = true;
- } /* else (S_ISDIR(inode->i_mode) && inode->i_nlink == 1) { ; } */
-
+ ldiskfs_inc_count(oh->ot_handle, inode);
LASSERT(inode->i_nlink <= LDISKFS_LINK_MAX);
spin_unlock(&obj->oo_guard);
- if (need_dirty)
- ll_dirty_inode(inode, I_DIRTY_DATASYNC);
-
+ ll_dirty_inode(inode, I_DIRTY_DATASYNC);
LINVRNT(osd_invariant(obj));
return rc;
struct osd_object *obj = osd_dt_obj(dt);
struct inode *inode = obj->oo_inode;
struct osd_device *osd = osd_dev(dt->do_lu.lo_dev);
+ struct osd_thandle *oh;
LINVRNT(osd_invariant(obj));
LASSERT(dt_object_exists(dt) && !dt_object_remote(dt));
LASSERT(osd_write_locked(env, obj));
LASSERT(th != NULL);
+ oh = container_of0(th, struct osd_thandle, ot_super);
+ LASSERT(oh->ot_handle != NULL);
+
osd_trans_exec_op(env, th, OSD_OT_REF_DEL);
spin_lock(&obj->oo_guard);
return 0;
}
- /* This based on ldiskfs_dec_count(), which is not exported.
- *
- * If a directory already has nlink == 1, then do not drop the nlink
- * count to 0, even temporarily, to avoid race conditions with other
- * threads not holding oo_guard seeing i_nlink == 0 in rare cases.
- *
- * nlink == 1 means the directory has/had > EXT4_LINK_MAX subdirs.
- */
- if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 1) {
- drop_nlink(inode);
+ ldiskfs_dec_count(oh->ot_handle, inode);
+ spin_unlock(&obj->oo_guard);
- spin_unlock(&obj->oo_guard);
- ll_dirty_inode(inode, I_DIRTY_DATASYNC);
- LINVRNT(osd_invariant(obj));
- } else {
- spin_unlock(&obj->oo_guard);
- }
+ ll_dirty_inode(inode, I_DIRTY_DATASYNC);
+ LINVRNT(osd_invariant(obj));
return 0;
}
down_write(&obj->oo_ext_idx_sem);
}
- bh = ldiskfs_find_entry(dir, &dentry->d_name, &de, hlock);
+ bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock);
if (bh) {
__u32 ino = 0;
down_read(&obj->oo_ext_idx_sem);
}
- bh = osd_ldiskfs_find_entry(dir, dentry, &de, hlock);
+ bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock);
if (bh) {
struct osd_thread_info *oti = osd_oti_get(env);
struct osd_inode_id *id = &oti->oti_id;
again:
if (dev->od_dirent_journal) {
- jh = ldiskfs_journal_start_sb(sb, credits);
+ jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, credits);
if (IS_ERR(jh)) {
rc = PTR_ERR(jh);
CERROR("%.16s: fail to start trans for dirent "
}
}
- bh = osd_ldiskfs_find_entry(dir, dentry, &de, hlock);
+ bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock);
/* For dot/dotdot entry, if there is not enough space to hold the
* FID-in-dirent, just keep them there. It only happens when the
* device upgraded from 1.8 or restored from MDT file-level backup.
return bh;
newblock:
- bh = ldiskfs_append(h, inode, b, e);
+ bh = osd_ldiskfs_append(h, inode, b, e);
return bh;
fail:
int ldiskfs_htree_next_block(struct inode *dir, __u32 hash,
struct iam_path *path, __u32 *start_hash);
-struct buffer_head *ldiskfs_append(handle_t *handle, struct inode *inode,
- u32 *block, int *err);
int split_index_node(handle_t *handle, struct iam_path *path,
struct dynlock_handle **lh);
struct ldiskfs_dir_entry_2 *split_entry(struct inode *dir,
struct super_block *sb;
u32 blknr;
- int result;
+ int result = 0;
unsigned long bsize;
assert_corr(obj->i_size == 0);
sb = obj->i_sb;
bsize = sb->s_blocksize;
- root_node = ldiskfs_append(handle, obj, &blknr, &result);
- leaf_node = ldiskfs_append(handle, obj, &blknr, &result);
+ root_node = osd_ldiskfs_append(handle, obj, &blknr, &result);
+ leaf_node = osd_ldiskfs_append(handle, obj, &blknr, &result);
if (root_node != NULL && leaf_node != NULL) {
lfix_root(root_node->b_data, bsize, keysize, ptrsize, recsize);
lfix_leaf(leaf_node->b_data, bsize, keysize, ptrsize, recsize);
struct super_block *sb;
u32 blknr;
- int result;
+ int result = 0;
unsigned long bsize;
assert_corr(obj->i_size == 0);
sb = obj->i_sb;
bsize = sb->s_blocksize;
- root_node = ldiskfs_append(handle, obj, &blknr, &result);
- leaf_node = ldiskfs_append(handle, obj, &blknr, &result);
+ root_node = osd_ldiskfs_append(handle, obj, &blknr, &result);
+ leaf_node = osd_ldiskfs_append(handle, obj, &blknr, &result);
if (root_node != NULL && leaf_node != NULL) {
lvar_root(root_node->b_data, bsize, keysize, ptrsize, recsize);
lvar_leaf(leaf_node->b_data, bsize, keysize, ptrsize, recsize);
struct dentry *omm_remote_parent;
};
-#define osd_ldiskfs_find_entry(dir, dentry, de, lock) \
- ll_ldiskfs_find_entry(dir, dentry, de, lock)
#define osd_ldiskfs_add_entry(handle, child, cinode, hlock) \
ldiskfs_add_entry(handle, child, cinode, hlock)
{
return (!fid_is_namespace_visible(fid) && !fid_is_idif(fid));
}
+
+#ifdef JOURNAL_START_HAS_3ARGS
+# define osd_journal_start_sb(sb, type, nblock) \
+ ldiskfs_journal_start_sb(sb, type, nblock)
+# define osd_ldiskfs_append(handle, inode, nblock, err) \
+ ldiskfs_append(handle, inode, nblock)
+# define osd_ldiskfs_find_entry(dir, name, de, inlined, lock) \
+ ldiskfs_find_entry(dir, name, de, inlined, lock)
+# define osd_journal_start(inode, type, nblocks) \
+ ldiskfs_journal_start(inode, type, nblocks);
+#else
+# define LDISKFS_HT_MISC 0
+# define osd_journal_start_sb(sb, type, nblock) \
+ ldiskfs_journal_start_sb(sb, nblock)
+# define osd_ldiskfs_append(handle, inode, nblock, err) \
+ ldiskfs_append(handle, inode, nblock, err)
+# define osd_ldiskfs_find_entry(dir, name, de, inlined, lock) \
+ ldiskfs_find_entry(dir, name, de, lock)
+# define osd_journal_start(inode, type, nblocks) \
+ ldiskfs_journal_start(inode, nblocks);
+#endif
+
+void ldiskfs_inc_count(handle_t *handle, struct inode *inode);
+void ldiskfs_dec_count(handle_t *handle, struct inode *inode);
+
#endif /* __KERNEL__ */
#endif /* _OSD_INTERNAL_H */
oldsize=inode->i_size;
i_size_write(inode, start);
truncate_pagecache(inode, oldsize, start);
+#ifdef HAVE_INODEOPS_TRUNCATE
if (inode->i_op->truncate)
inode->i_op->truncate(inode);
+#else
+ if (!(inode->i_state & (I_NEW|I_FREEING)))
+ mutex_lock(&inode->i_mutex);
+ ldiskfs_truncate(inode);
+ if (!(inode->i_state & (I_NEW|I_FREEING)))
+ mutex_unlock(&inode->i_mutex);
+#endif
/*
* For a partial-page truncate, flush the page to disk immediately to
int rc;
dentry = osd_child_dentry_by_inode(env, dir, name, strlen(name));
- bh = osd_ldiskfs_find_entry(dir, dentry, &de, NULL);
+ bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, NULL);
if (bh) {
osd_id_gen(id, le32_to_cpu(de->inode), OSD_OII_NOGEN);
brelse(bh);
return PTR_ERR(inode);
}
- jh = ldiskfs_journal_start_sb(sb, 100);
+ jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, 100);
if (IS_ERR(jh))
return PTR_ERR(jh);
struct lquota_acct_rec *rec = (struct lquota_acct_rec *)dtrec;
__u64 id = *((__u64 *)dtkey);
int rc;
+#ifdef HAVE_DQUOT_KQID
+ struct kqid qid;
+#endif
ENTRY;
memset((void *)dqblk, 0, sizeof(struct obd_dqblk));
+#ifdef HAVE_DQUOT_KQID
+ qid = make_kqid(&init_user_ns, obj2type(dtobj), id);
+ rc = sb->s_qcop->get_dqblk(sb, qid, dqblk);
+#else
rc = sb->s_qcop->get_dqblk(sb, obj2type(dtobj), (qid_t) id, dqblk);
+#endif
if (rc)
RETURN(rc);
#ifdef HAVE_DQUOT_FS_DISK_QUOTA
dev = container_of0(scrub, struct osd_device, od_scrub);
credits = osd_dto_credits_noquota[DTO_WRITE_BASE] +
osd_dto_credits_noquota[DTO_WRITE_BLOCK];
- jh = ldiskfs_journal_start_sb(osd_sb(dev), credits);
+ jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC, credits);
if (IS_ERR(jh)) {
rc = PTR_ERR(jh);
CERROR("%.16s: fail to start trans for scrub store, rc = %d\n",
* Making the LMA to fit into the 256-byte OST inode can save time for
* normal osd_check_lma() and for other OI scrub scanning in future.
* So it is worth to make some slow conversion here. */
- jh = ldiskfs_journal_start_sb(osd_sb(dev),
+ jh = osd_journal_start_sb(osd_sb(dev), LDISKFS_HT_MISC,
osd_dto_credits_noquota[DTO_XATTR_SET] * 3);
if (IS_ERR(jh)) {
rc = PTR_ERR(jh);