Skip to content

Commit

Permalink
Fixes for Rust 1.72 (#479)
Browse files Browse the repository at this point in the history
* Fixes for Rust 1.72

Signed-off-by: James Bornholt <[email protected]>

* Fix tracing

Signed-off-by: James Bornholt <[email protected]>

---------

Signed-off-by: James Bornholt <[email protected]>
  • Loading branch information
jamesbornholt authored Aug 25, 2023
1 parent 6103a2f commit c7464d0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"mountpoint-s3",
"vendor/fuser",
]
resolver = "2"

[profile.release]
debug = 2
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ fmt-check:
done; \
exit $$fail

DISABLED_LINTS =
DISABLED_LINTS += -A clippy::items-after-test-module # https://github.com/rust-lang/rust-clippy/issues/11153
DISABLED_LINTS += -A clippy::arc-with-non-send-sync # https://github.com/proptest-rs/proptest/issues/364

.PHONY: clippy
clippy:
@packages=`echo "$(CRATES)" | sed -E 's/(^| )/ -p /g'`; \
cargo clippy $$packages --no-deps --all-targets --all-features -- -D clippy::all -A clippy::items-after-test-module
cargo clippy $$packages --no-deps --all-targets --all-features -- -D clippy::all $(DISABLED_LINTS)
2 changes: 1 addition & 1 deletion mountpoint-s3-client/tests/put_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async fn test_put_object_multi_part(client: &impl ObjectClient, bucket: &str, pr

let key = format!("{prefix}hello");

let mut contents = vec![0u8; 32];
let mut contents = [0u8; 32];
rng.fill(&mut contents[..]);

let mut request = client
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3-crt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<T> CrtError for *mut T {
type Return = NonNull<T>;

unsafe fn ok_or_last_error(self) -> Result<Self::Return, Error> {
NonNull::new(self as *mut T).ok_or_else(|| Error::last_error())
NonNull::new(self).ok_or_else(|| Error::last_error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3-crt/src/s3/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ unsafe extern "C" fn meta_request_telemetry_callback(
let user_data = MetaRequestOptionsInner::from_user_data_ptr(user_data);

if let Some(callback) = user_data.on_telemetry.as_ref() {
let metrics = NonNull::new(metrics as *mut aws_s3_request_metrics).expect("request metrics is never null");
let metrics = NonNull::new(metrics).expect("request metrics is never null");
let metrics = RequestMetrics { inner: metrics };
// The docs say "`metrics` is only valid for the duration of the callback", so we need to
// pass a reference here.
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ regex = "1.7.1"
supports-color = "2.0.0"
syslog = "6.1.0"
thiserror = "1.0.34"
tracing = { version = "0.1.35", default-features = false, features = ["std", "log"] }
tracing = { version = "0.1.35", default-features = false, features = ["std", "log", "attributes"] }
tracing-log = "0.1.3"
tracing-subscriber = { version = "0.3.14", features = ["fmt", "env-filter"] }
nix = "0.26.2"
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3/src/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ where
name: &OsStr,
newparent: u64,
newname: &OsStr,
options: u64,
_options: u64,
reply: ReplyEmpty,
) {
fuse_unsupported!("exchange", reply);
Expand Down
18 changes: 11 additions & 7 deletions mountpoint-s3/src/fuse/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,17 @@ impl<W: Work> WorkerPool<W> {
/// Try to add a new worker.
/// Returns `Ok(false)` if there are already [`WorkerPool::max_workers`].
fn try_add_worker(&self) -> anyhow::Result<bool> {
let Ok(i) = self.state.worker_count.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |i| {
if i < self.max_workers {
Some(i + 1)
} else {
None
}
}) else {
let Ok(i) = self
.state
.worker_count
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |i| {
if i < self.max_workers {
Some(i + 1)
} else {
None
}
})
else {
return Ok(false);
};
self.state.idle_worker_count.fetch_add(1, Ordering::SeqCst);
Expand Down
14 changes: 12 additions & 2 deletions mountpoint-s3/src/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ impl Superblock {
return;
};
let mut parent_state = parent.inner.sync.write().unwrap();
let InodeKindData::Directory { children, writing_children, .. } = &mut parent_state.kind_data else {
let InodeKindData::Directory {
children,
writing_children,
..
} = &mut parent_state.kind_data
else {
unreachable!("parent is always a directory");
};
if let Some(child) = children.get(inode.name()) {
Expand Down Expand Up @@ -745,7 +750,12 @@ impl SuperblockInner {
match (remote, inode) {
(None, None) => Err(InodeError::FileDoesNotExist),
(None, Some(existing_inode)) => {
let InodeKindData::Directory { children, writing_children, .. } = &mut parent_state.kind_data else {
let InodeKindData::Directory {
children,
writing_children,
..
} = &mut parent_state.kind_data
else {
unreachable!("we know parent is a directory");
};
if writing_children.contains(&existing_inode.ino()) {
Expand Down

0 comments on commit c7464d0

Please sign in to comment.