Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xfs: parent pointer attribute creation
Add parent pointer attribute during xfs_create, and subroutines to initialize attributes [bfoster: rebase, use VFS inode generation] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, fixed some null pointer bugs, merged error handling patch, added subroutines to handle attribute initialization, remove unnecessary ENOSPC handling in xfs_attr_set_first_parent] Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
- Loading branch information
1 parent
4801b66
commit 6f41023
Showing
7 changed files
with
177 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2015 Red Hat, Inc. | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it would be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write the Free Software Foundation | ||
*/ | ||
#include "xfs.h" | ||
#include "xfs_fs.h" | ||
#include "xfs_format.h" | ||
#include "xfs_da_format.h" | ||
#include "xfs_log_format.h" | ||
#include "xfs_shared.h" | ||
#include "xfs_trans_resv.h" | ||
#include "xfs_mount.h" | ||
#include "xfs_bmap_btree.h" | ||
#include "xfs_inode.h" | ||
#include "xfs_error.h" | ||
#include "xfs_trace.h" | ||
#include "xfs_trans.h" | ||
#include "xfs_da_btree.h" | ||
#include "xfs_attr.h" | ||
#include "xfs_da_btree.h" | ||
#include "xfs_attr_sf.h" | ||
#include "xfs_bmap.h" | ||
|
||
/* | ||
* Parent pointer attribute handling. | ||
* | ||
* Because the attribute value is a filename component, it will never be longer | ||
* than 255 bytes. This means the attribute will always be a local format | ||
* attribute as it is xfs_attr_leaf_entsize_local_max() for v5 filesystems will | ||
* always be larger than this (max is 75% of block size). | ||
* | ||
* Creating a new parent attribute will always create a new attribute - there | ||
* should never, ever be an existing attribute in the tree for a new inode. | ||
* ENOSPC behavior is problematic - creating the inode without the parent | ||
* pointer is effectively a corruption, so we allow parent attribute creation | ||
* to dip into the reserve block pool to avoid unexpected ENOSPC errors from | ||
* occurring. | ||
*/ | ||
|
||
|
||
/* Initializes a xfs_parent_name_rec to be stored as an attribute name */ | ||
void | ||
xfs_init_parent_name_rec( | ||
struct xfs_parent_name_rec *rec, | ||
struct xfs_inode *ip, | ||
uint32_t p_diroffset) | ||
{ | ||
xfs_ino_t p_ino = ip->i_ino; | ||
uint32_t p_gen = VFS_I(ip)->i_generation; | ||
|
||
rec->p_ino = cpu_to_be64(p_ino); | ||
rec->p_gen = cpu_to_be32(p_gen); | ||
rec->p_diroffset = cpu_to_be32(p_diroffset); | ||
} | ||
|
||
/* Initializes a xfs_parent_name_irec from an xfs_parent_name_rec */ | ||
void | ||
xfs_init_parent_name_irec( | ||
struct xfs_parent_name_irec *irec, | ||
struct xfs_parent_name_rec *rec) | ||
{ | ||
irec->p_ino = be64_to_cpu(rec->p_ino); | ||
irec->p_gen = be32_to_cpu(rec->p_gen); | ||
irec->p_diroffset = be32_to_cpu(rec->p_diroffset); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2018 Oracle, Inc. | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it would be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write the Free Software Foundation Inc. | ||
*/ | ||
#ifndef __XFS_PARENT_H__ | ||
#define __XFS_PARENT_H__ | ||
|
||
#include "xfs_da_format.h" | ||
#include "xfs_format.h" | ||
|
||
/* | ||
* Parent pointer attribute prototypes | ||
*/ | ||
void xfs_init_parent_name_rec(struct xfs_parent_name_rec *rec, | ||
struct xfs_inode *ip, | ||
uint32_t p_diroffset); | ||
void xfs_init_parent_name_irec(struct xfs_parent_name_irec *irec, | ||
struct xfs_parent_name_rec *rec); | ||
#endif /* __XFS_PARENT_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters