1
0
mirror of https://github.com/ceph/ceph synced 2024-12-17 00:46:05 +00:00

handle inodes collisions in 32 bit architectures

This commit is contained in:
Yehuda Sadeh-Weinraub 2008-03-12 13:11:34 +02:00
parent c5070ff4bd
commit 59f5ac86c5
4 changed files with 39 additions and 8 deletions

View File

@ -82,7 +82,7 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc)
inode, page, page->index);
/* write a page at the index of page->index, by size of PAGE_SIZE */
err = ceph_osdc_writepage(osdc, inode->i_ino, &ci->i_layout,
err = ceph_osdc_writepage(osdc, ceph_ino(inode), &ci->i_layout,
page->index << PAGE_SHIFT, PAGE_SIZE, page);
if (err)
goto out_unlock;
@ -153,7 +153,7 @@ static int ceph_prepare_write(struct file *filp, struct page *page,
/* Now it's clear that the page is not up to date */
err = ceph_osdc_prepare_write(osdc, inode->i_ino, &ci->i_layout,
err = ceph_osdc_prepare_write(osdc, ceph_ino(inode), &ci->i_layout,
page->index << PAGE_SHIFT, PAGE_SIZE,
page);
if (err)
@ -198,7 +198,7 @@ static int ceph_commit_write(struct file *filp, struct page *page,
position = ((loff_t)page->index << PAGE_SHIFT) + from;
page_data = kmap(page);
err = ceph_osdc_commit_write(osdc, inode->i_ino, &ci->i_layout,
err = ceph_osdc_commit_write(osdc, ceph_ino(inode), &ci->i_layout,
page->index << PAGE_SHIFT,
PAGE_SIZE,
page);

View File

@ -18,18 +18,25 @@ const struct inode_operations ceph_symlink_iops;
int ceph_get_inode(struct super_block *sb, __u64 ino, struct inode **pinode)
{
struct ceph_inode_info *ci;
ino_t inot;
BUG_ON(pinode == NULL);
inot = ceph_ino_to_ino(ino);
#if BITS_PER_LONG == 64
*pinode = iget_locked(sb, ino);
#else
*pinode = iget5_locked(sb, inot, ceph_ino_compare, ceph_set_ino_cb, &ino);
#endif
if (*pinode == NULL)
return -ENOMEM;
if ((*pinode)->i_state & I_NEW)
unlock_new_inode(*pinode);
ci = ceph_inode(*pinode);
#if BITS_PER_LONG == 64
ceph_set_ino(*pinode, ino);
#endif
ci->i_hashval = (*pinode)->i_ino;
dout(30, "get_inode on %lu=%llx got %p\n", (*pinode)->i_ino, ino, *pinode);
@ -429,6 +436,7 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant,
if (wanted == 0) {
dout(10, "wanted=0, reminding mds\n");
grant->wanted = cpu_to_le32(0);
spin_unlock(&inode->i_lock);
return 1; /* ack */
}
/* hrm */

View File

@ -1241,15 +1241,20 @@ void ceph_mdsc_handle_filecaps(struct ceph_mds_client *mdsc,
/* lookup ino */
inot = ceph_ino_to_ino(ino);
inode = ilookup(sb, inot);
#if BITS_PER_LONG == 64
inode = ilookup(sb, ino);
#else
inode = ilookup5(sb, inot, ceph_ino_compare, &ino);
#endif
dout(20, "op is %d, ino %llx %p\n", op, ino, inode);
if (inode && ceph_ino(inode) != inot) {
if (inode && ceph_ino(inode) != ino) {
BUG_ON(sizeof(ino_t) >= sizeof(u64));
dout(10, "UH OH, lame ceph ino %llx -> %lu ino_t hash collided?"
" inode is %llx\n", ino, inot, ceph_ino(inode));
inode = 0;
}
if (!inode) {
dout(10, "wtf, i don't have ino %lu=%llx? closing out cap\n",
inot, ino);

View File

@ -176,22 +176,40 @@ static inline struct ceph_inode_info *ceph_inode(struct inode *inode)
static inline ino_t ceph_ino_to_ino(u64 cephino)
{
ino_t ino = (ino_t)cephino;
if (sizeof(ino_t) < sizeof(u64))
ino ^= cephino >> (sizeof(u64)-sizeof(ino_t)) * 8;
#if BITS_PER_LONG == 32
ino ^= cephino >> (sizeof(u64)-sizeof(ino_t)) * 8;
#endif
return ino;
}
static inline void ceph_set_ino(struct inode *inode, __u64 ino)
{
struct ceph_inode_info *ci = ceph_inode(inode);
ci->i_ceph_ino = ino;
inode->i_ino = ceph_ino_to_ino(ino);
}
static inline int ceph_set_ino_cb(struct inode *inode, void *data)
{
ceph_set_ino(inode, *(__u64 *)data);
return 0;
}
static inline u64 ceph_ino(struct inode *inode)
{
struct ceph_inode_info *ci = ceph_inode(inode);
return ci->i_ceph_ino;
}
static inline int ceph_ino_compare(struct inode *inode, void *data)
{
__u64 ino = *(__u64 *)data;
struct ceph_inode_info *ci = ceph_inode(inode);
return (ci->i_ceph_ino == ino);
}
/*
* caps helpers
*/