Пример #1
0
int osd_compat_add_entry(struct osd_thread_info *info, struct osd_device *osd,
                         struct dentry *dir, char *name,
                         const struct osd_inode_id *id, struct thandle *th)
{
        struct osd_thandle *oh;
        struct dentry *child;
        struct inode *inode;
        int rc;

        ENTRY;

        oh = container_of(th, struct osd_thandle, ot_super);
        LASSERT(oh->ot_handle != NULL);
        LASSERT(oh->ot_handle->h_transaction != NULL);

        inode = &info->oti_inode;
        inode->i_sb = osd_sb(osd);
        inode->i_ino = id->oii_ino;
        inode->i_generation = id->oii_gen;

        child = &info->oti_child_dentry;
        child->d_name.hash = 0;
        child->d_name.name = name;
        child->d_name.len = strlen(name);
        child->d_parent = dir;
        child->d_inode = inode;

        LOCK_INODE_MUTEX(dir->d_inode);
        rc = osd_ldiskfs_add_entry(oh->ot_handle, child, inode, NULL);
        UNLOCK_INODE_MUTEX(dir->d_inode);

        RETURN(rc);
}
Пример #2
0
int osd_compat_del_entry(struct osd_thread_info *info, struct osd_device *osd,
                         struct dentry *dird, char *name, struct thandle *th)
{
        struct ldiskfs_dir_entry_2 *de;
        struct buffer_head         *bh;
        struct osd_thandle         *oh;
        struct dentry              *child;
        struct inode               *dir = dird->d_inode;
        int                         rc;

        ENTRY;

        oh = container_of(th, struct osd_thandle, ot_super);
        LASSERT(oh->ot_handle != NULL);
        LASSERT(oh->ot_handle->h_transaction != NULL);


        child = &info->oti_child_dentry;
        child->d_name.hash = 0;
        child->d_name.name = name;
        child->d_name.len = strlen(name);
        child->d_parent = dird;
        child->d_inode = NULL;

        LOCK_INODE_MUTEX(dir);
        rc = -ENOENT;
        bh = osd_ldiskfs_find_entry(dir, child, &de, NULL);
        if (bh) {
                rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh);
                brelse(bh);
        }
        UNLOCK_INODE_MUTEX(dir);

        RETURN(rc);
}
Пример #3
0
int filter_log_sz_change(struct llog_handle *cathandle,
                         struct ll_fid *mds_fid,
                         __u32 ioepoch,
                         struct llog_cookie *logcookie,
                         struct inode *inode)
{
        struct llog_size_change_rec *lsc;
        int rc;
        struct ost_filterdata *ofd;
        ENTRY;

        LOCK_INODE_MUTEX(inode);
        ofd = INODE_PRIVATE_DATA(inode);

        if (ofd && ofd->ofd_epoch >= ioepoch) {
                if (ofd->ofd_epoch > ioepoch)
                        CERROR("client sent old epoch %d for obj ino %ld\n",
                               ioepoch, inode->i_ino);
                UNLOCK_INODE_MUTEX(inode);
                RETURN(0);
        }

        if (ofd && ofd->ofd_epoch < ioepoch) {
                ofd->ofd_epoch = ioepoch;
        } else if (!ofd) {
                OBD_ALLOC(ofd, sizeof(*ofd));
                if (!ofd)
                        GOTO(out, rc = -ENOMEM);
                igrab(inode);
                INODE_PRIVATE_DATA(inode) = ofd;
                ofd->ofd_epoch = ioepoch;
        }
        /* the decision to write a record is now made, unlock */
        UNLOCK_INODE_MUTEX(inode);

        OBD_ALLOC(lsc, sizeof(*lsc));
        if (lsc == NULL)
                RETURN(-ENOMEM);
        lsc->lsc_hdr.lrh_len = lsc->lsc_tail.lrt_len = sizeof(*lsc);
        lsc->lsc_hdr.lrh_type =  OST_SZ_REC;
        lsc->lsc_fid = *mds_fid;
        lsc->lsc_ioepoch = ioepoch;

        rc = llog_cat_add_rec(cathandle, &lsc->lsc_hdr, logcookie, NULL);
        OBD_FREE(lsc, sizeof(*lsc));

        if (rc > 0) {
                LASSERT(rc == sizeof(*logcookie));
                rc = 0;
        }

        out:
        RETURN(rc);
}
Пример #4
0
int l_notify_change(struct vfsmount *mnt, struct dentry *dchild,
                 struct iattr *newattrs)
{
        int rc;

        LOCK_INODE_MUTEX(dchild->d_inode);
#ifdef HAVE_SECURITY_PLUG
        rc = notify_change(dchild, mnt, newattrs);
#else
        rc = notify_change(dchild, newattrs);
#endif
        UNLOCK_INODE_MUTEX(dchild->d_inode);
        return rc;
}
Пример #5
0
int osd_compat_objid_lookup(struct osd_thread_info *info,
                            struct osd_device *dev, const struct lu_fid *fid,
                            struct osd_inode_id *id)
{
        struct osd_compat_objid    *map;
        struct dentry              *d;
        struct dentry              *d_seq;
        struct ost_id              *ostid = &info->oti_ostid;
        int                         rc = 0;
        int                         dirn;
        char                        name[32];
        struct ldiskfs_dir_entry_2 *de;
        struct buffer_head         *bh;
        struct inode               *dir;
        ENTRY;

        /* on the very first lookup we find and open directories */

        map = dev->od_ost_map;
        LASSERT(map);
        LASSERT(map->root);

        fid_ostid_pack(fid, ostid);
        LASSERT(ostid->oi_seq < MAX_OBJID_GROUP);
        LASSERT(map->subdir_count > 0);
        LASSERT(map->groups[ostid->oi_seq].groot);

        dirn = ostid->oi_id & (map->subdir_count - 1);
        d = map->groups[ostid->oi_seq].dirs[dirn];
        LASSERT(d);

        sprintf(name, "%llu", ostid->oi_id);
        d_seq = &info->oti_child_dentry;
        d_seq->d_parent = d;
        d_seq->d_name.hash = 0;
        d_seq->d_name.name = name;
        /* XXX: we can use rc from sprintf() instead of strlen() */
        d_seq->d_name.len = strlen(name);

        dir = d->d_inode;
        LOCK_INODE_MUTEX(dir);
        bh = osd_ldiskfs_find_entry(dir, d_seq, &de, NULL);
        UNLOCK_INODE_MUTEX(dir);

        rc = -ENOENT;
        if (bh) {
                struct inode *inode;

                id->oii_ino = le32_to_cpu(de->inode);
                brelse(bh);

                id->oii_gen = OSD_OII_NOGEN;
                inode = osd_iget(info, dev, id);

                if (IS_ERR(inode))
                        GOTO(cleanup, rc = PTR_ERR(inode));
                rc = 0;
                id->oii_gen = inode->i_generation;
                iput(inode);
        }

cleanup:
        RETURN(rc);
}