From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4788C433B4 for ; Mon, 10 May 2021 16:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96B0B613CF for ; Mon, 10 May 2021 16:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbhEJQRX (ORCPT ); Mon, 10 May 2021 12:17:23 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:42380 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbhEJQRS (ORCPT ); Mon, 10 May 2021 12:17:18 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lg8Zi-003wZY-PY; Mon, 10 May 2021 10:16:06 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=fess.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1lg8Zg-0006F8-2L; Mon, 10 May 2021 10:16:06 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Al Viro Cc: Linus Torvalds , Jia He , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Jonathan Corbet , Al Viro , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "Darrick J. Wong" , "Peter Zijlstra \(Intel\)" , Ira Weiny , Eric Biggers , "Ahmed S. Darwish" , "open list\:DOCUMENTATION" , Linux Kernel Mailing List , linux-s390 , linux-fsdevel References: <20210508122530.1971-1-justin.he@arm.com> <20210508122530.1971-2-justin.he@arm.com> Date: Mon, 10 May 2021 11:16:00 -0500 In-Reply-To: (Al Viro's message of "Sun, 9 May 2021 02:20:32 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1lg8Zg-0006F8-2L;;;mid=;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/yBPTimQoWRMQi9KZ501san+bfHriGOc0= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH RFC 1/3] fs: introduce helper d_path_fast() X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Al Viro writes: > > Another thing that keeps bugging me about prepend_path() is the > set of return values. I mean, 0/1/2/3/-ENAMETOOLONG, and all > except 0 are unlikely? Might as well make that 0/1/2/3/-1, if > not an outright 0/1/2/3/4. And prepend() could return bool, while > we are at it (true - success, false - overflow)... I remember seeing that the different callers of prepend_path treated those different cases differently. But now that I look again the return value 3 (escaped) gets lumped together with 2(detached). On second look it appears that the two patterns that we actually have are basically: char *__d_path(const struct path *path, const struct path *root, char *buf, int buflen) { error = prepend_path(path, root, &res, &buflen); if (error < 0) return ERR_PTR(error); if (error > 0) return NULL; return res; } char *d_absolute_path(const struct path *path, char *buf, int buflen) { error = prepend_path(path, &root, &res, &buflen); if (error > 1) error = -EINVAL; if (error < 0) return ERR_PTR(error); return res; } With d_absolute_path deciding that return value 1 absolute is not an error. That does look like there is plenty of room to refactor and make things clearer. Eric