* [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag
@ 2024-02-14 9:52 Gabriel Goller
2024-02-14 9:52 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context Gabriel Goller
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Gabriel Goller @ 2024-02-14 9:52 UTC (permalink / raw)
To: pbs-devel
Some filesystems (f.e. zfs) support xattrs bigger than 64kB, sadly we
can't get them because the kernel vfs limits us. The syscalls listxattr
and getxattr will return a E2BIG error in this case.
Added a flag --ignore-e2big-xattr to the client, this will ignore the
metadata (but still backup the file) if this error occurs.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
pbs-client/src/pxar/create.rs | 28 +++++++++++++++++--
proxmox-backup-client/src/main.rs | 8 ++++++
.../src/proxmox_restore_daemon/api.rs | 1 +
pxar-bin/src/main.rs | 1 +
4 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index e7053d9e..6dac95d9 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -7,7 +7,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
-use anyhow::{bail, Context, Error};
+use anyhow::{bail, Context, Error, format_err};
use futures::future::BoxFuture;
use futures::FutureExt;
use nix::dir::Dir;
@@ -41,6 +41,8 @@ pub struct PxarCreateOptions {
pub entries_max: usize,
/// Skip lost+found directory
pub skip_lost_and_found: bool,
+ /// Skip xattrs of files that return E2BIG error
+ pub skip_e2big_xattr: bool,
}
fn detect_fs_type(fd: RawFd) -> Result<i64, Error> {
@@ -128,6 +130,7 @@ struct Archiver {
device_set: Option<HashSet<u64>>,
hardlinks: HashMap<HardLinkInfo, (PathBuf, LinkOffset)>,
file_copy_buffer: Vec<u8>,
+ skip_e2big_xattr: bool,
}
type Encoder<'a, T> = pxar::encoder::aio::Encoder<'a, T>;
@@ -158,6 +161,7 @@ where
feature_flags & fs_feature_flags,
fs_magic,
&mut fs_feature_flags,
+ options.skip_e2big_xattr
)
.context("failed to get metadata for source directory")?;
@@ -192,6 +196,7 @@ where
device_set,
hardlinks: HashMap::new(),
file_copy_buffer: vec::undefined(4 * 1024 * 1024),
+ skip_e2big_xattr: options.skip_e2big_xattr,
};
archiver
@@ -540,6 +545,7 @@ impl Archiver {
self.flags(),
self.fs_magic,
&mut self.fs_feature_flags,
+ self.skip_e2big_xattr
)?;
let match_path = PathBuf::from("/").join(self.path.clone());
@@ -765,6 +771,7 @@ fn get_metadata(
flags: Flags,
fs_magic: i64,
fs_feature_flags: &mut Flags,
+ skip_e2big_xattr: bool,
) -> Result<Metadata, Error> {
// required for some of these
let proc_path = Path::new("/proc/self/fd/").join(fd.to_string());
@@ -780,7 +787,7 @@ fn get_metadata(
..Default::default()
};
- get_xattr_fcaps_acl(&mut meta, fd, &proc_path, flags, fs_feature_flags)?;
+ get_xattr_fcaps_acl(&mut meta, fd, &proc_path, flags, fs_feature_flags, skip_e2big_xattr)?;
get_chattr(&mut meta, fd)?;
get_fat_attr(&mut meta, fd, fs_magic)?;
get_quota_project_id(&mut meta, fd, flags, fs_magic)?;
@@ -818,6 +825,7 @@ fn get_xattr_fcaps_acl(
proc_path: &Path,
flags: Flags,
fs_feature_flags: &mut Flags,
+ skip_e2big_xattr: bool,
) -> Result<(), Error> {
if !flags.contains(Flags::WITH_XATTRS) {
return Ok(());
@@ -829,6 +837,14 @@ fn get_xattr_fcaps_acl(
fs_feature_flags.remove(Flags::WITH_XATTRS);
return Ok(());
}
+ Err(Errno::E2BIG) => {
+ match skip_e2big_xattr {
+ true => return Ok(()),
+ false => {
+ return Err(format_err!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string()));
+ }
+ };
+ }
Err(Errno::EBADF) => return Ok(()), // symlinks
Err(err) => return Err(err).context("failed to read xattrs"),
};
@@ -855,6 +871,14 @@ fn get_xattr_fcaps_acl(
Err(Errno::ENODATA) => (), // it got removed while we were iterating...
Err(Errno::EOPNOTSUPP) => (), // shouldn't be possible so just ignore this
Err(Errno::EBADF) => (), // symlinks, shouldn't be able to reach this either
+ Err(Errno::E2BIG) => {
+ match skip_e2big_xattr {
+ true => return Ok(()),
+ false => {
+ return Err(format_err!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string()));
+ }
+ };
+ }
Err(err) => {
return Err(err).context(format!("error reading extended attribute {attr:?}"))
}
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index e5caf87d..fdf43747 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -665,6 +665,12 @@ fn spawn_catalog_upload(
optional: true,
default: false,
},
+ "skip-e2big-xattr": {
+ type: Boolean,
+ description: "Ignore the E2BIG error when retrieving xattrs. This includes the file, but discards the metadata.",
+ optional: true,
+ default: false,
+ },
}
}
)]
@@ -674,6 +680,7 @@ async fn create_backup(
all_file_systems: bool,
skip_lost_and_found: bool,
dry_run: bool,
+ skip_e2big_xattr: bool,
_info: &ApiMethod,
_rpcenv: &mut dyn RpcEnvironment,
) -> Result<Value, Error> {
@@ -993,6 +1000,7 @@ async fn create_backup(
patterns: pattern_list.clone(),
entries_max: entries_max as usize,
skip_lost_and_found,
+ skip_e2big_xattr
};
let upload_options = UploadOptions {
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index c4e97d33..c2055222 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -352,6 +352,7 @@ fn extract(
device_set: None,
patterns,
skip_lost_and_found: false,
+ skip_e2big_xattr: false,
};
let pxar_writer = TokioWriter::new(writer);
diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs
index bc044035..2bbe90e3 100644
--- a/pxar-bin/src/main.rs
+++ b/pxar-bin/src/main.rs
@@ -335,6 +335,7 @@ async fn create_archive(
device_set,
patterns,
skip_lost_and_found: false,
+ skip_e2big_xattr: false,
};
let source = PathBuf::from(source);
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context
2024-02-14 9:52 [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Gabriel Goller
@ 2024-02-14 9:52 ` Gabriel Goller
2024-02-15 9:33 ` Dietmar Maurer
2024-02-15 8:26 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Dietmar Maurer
2024-02-15 9:37 ` [pbs-devel] applied: " Dietmar Maurer
2 siblings, 1 reply; 5+ messages in thread
From: Gabriel Goller @ 2024-02-14 9:52 UTC (permalink / raw)
To: pbs-devel
When printing an anyhow::Error using the "{}" formatter, only the outer
error will be printed. When using "{:#}" (pretty-print), the whole error
with all the contexts will be displayed.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
pbs-client/src/pxar/create.rs | 2 +-
pbs-client/src/pxar_backup_stream.rs | 2 +-
proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index 6dac95d9..4cb095cd 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -105,7 +105,7 @@ impl std::error::Error for ArchiveError {}
impl fmt::Display for ArchiveError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "error at {:?}: {}", self.path, self.error)
+ write!(f, "error at {:?}: {:#}", self.path, self.error)
}
}
diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs
index 22a6ffdc..61aee7c2 100644
--- a/pbs-client/src/pxar_backup_stream.rs
+++ b/pbs-client/src/pxar_backup_stream.rs
@@ -68,7 +68,7 @@ impl PxarBackupStream {
.await
{
let mut error = error2.lock().unwrap();
- *error = Some(err.to_string());
+ *error = Some(format!("{:#}", err));
}
};
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index c2055222..d0e09e15 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -361,7 +361,7 @@ fn extract(
}
.await;
if let Err(err) = result {
- error!("pxar streaming task failed - {}", err);
+ error!("pxar streaming task failed - {:#}", err);
}
});
} else if format == "tar" {
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context
2024-02-14 9:52 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context Gabriel Goller
@ 2024-02-15 9:33 ` Dietmar Maurer
0 siblings, 0 replies; 5+ messages in thread
From: Dietmar Maurer @ 2024-02-15 9:33 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Gabriel Goller
As discussed offline, we first need a strategy how to handle error
properly (i.e. we talked about using context instead of string concatenation).
So I will not apply this for now..
> On 14.2.2024 10:52 CET Gabriel Goller <g.goller@proxmox.com> wrote:
>
>
> When printing an anyhow::Error using the "{}" formatter, only the outer
> error will be printed. When using "{:#}" (pretty-print), the whole error
> with all the contexts will be displayed.
>
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
> pbs-client/src/pxar/create.rs | 2 +-
> pbs-client/src/pxar_backup_stream.rs | 2 +-
> proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
> index 6dac95d9..4cb095cd 100644
> --- a/pbs-client/src/pxar/create.rs
> +++ b/pbs-client/src/pxar/create.rs
> @@ -105,7 +105,7 @@ impl std::error::Error for ArchiveError {}
>
> impl fmt::Display for ArchiveError {
> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
> - write!(f, "error at {:?}: {}", self.path, self.error)
> + write!(f, "error at {:?}: {:#}", self.path, self.error)
> }
> }
>
> diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs
> index 22a6ffdc..61aee7c2 100644
> --- a/pbs-client/src/pxar_backup_stream.rs
> +++ b/pbs-client/src/pxar_backup_stream.rs
> @@ -68,7 +68,7 @@ impl PxarBackupStream {
> .await
> {
> let mut error = error2.lock().unwrap();
> - *error = Some(err.to_string());
> + *error = Some(format!("{:#}", err));
> }
> };
>
> diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
> index c2055222..d0e09e15 100644
> --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
> +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
> @@ -361,7 +361,7 @@ fn extract(
> }
> .await;
> if let Err(err) = result {
> - error!("pxar streaming task failed - {}", err);
> + error!("pxar streaming task failed - {:#}", err);
> }
> });
> } else if format == "tar" {
> --
> 2.43.0
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag
2024-02-14 9:52 [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Gabriel Goller
2024-02-14 9:52 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context Gabriel Goller
@ 2024-02-15 8:26 ` Dietmar Maurer
2024-02-15 9:37 ` [pbs-devel] applied: " Dietmar Maurer
2 siblings, 0 replies; 5+ messages in thread
From: Dietmar Maurer @ 2024-02-15 8:26 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Gabriel Goller
comments inline,
> + Err(Errno::E2BIG) => {
> + match skip_e2big_xattr {
> + true => return Ok(()),
> + false => {
> + return Err(format_err!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string()));
I now wonder why you do not simply use "bail!"?
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index a31086e2..75376c0c 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -7,7 +7,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
-use anyhow::{bail, Context, Error, format_err};
+use anyhow::{bail, Context, Error};
use futures::future::BoxFuture;
use futures::FutureExt;
use nix::dir::Dir;
@@ -841,7 +841,7 @@ fn get_xattr_fcaps_acl(
match skip_e2big_xattr {
true => return Ok(()),
false => {
- return Err(format_err!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string()));
+ bail!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string());
}
};
}
@@ -875,7 +875,7 @@ fn get_xattr_fcaps_acl(
match skip_e2big_xattr {
true => return Ok(()),
false => {
- return Err(format_err!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string()));
+ bail!("{} (try --skip-e2big-xattr)", Errno::E2BIG.to_string());
}
};
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag
2024-02-14 9:52 [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Gabriel Goller
2024-02-14 9:52 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context Gabriel Goller
2024-02-15 8:26 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Dietmar Maurer
@ 2024-02-15 9:37 ` Dietmar Maurer
2 siblings, 0 replies; 5+ messages in thread
From: Dietmar Maurer @ 2024-02-15 9:37 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Gabriel Goller
applied (but using bail instead of format_err)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-15 9:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 9:52 [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Gabriel Goller
2024-02-14 9:52 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] print full anyhow error context Gabriel Goller
2024-02-15 9:33 ` Dietmar Maurer
2024-02-15 8:26 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] fix #4975: client: ignore E2BIG error flag Dietmar Maurer
2024-02-15 9:37 ` [pbs-devel] applied: " Dietmar Maurer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox